MCPcopy Create free account
hub / github.com/foxcpp/maddy / Data

Method Data

internal/endpoint/smtp/session.go:451–495  ·  view source on GitHub ↗
(r io.Reader)

Source from the content-addressed store, hash-verified

449}
450
451func (s *Session) Data(r io.Reader) error {
452 s.msgLock.Lock()
453 defer s.msgLock.Unlock()
454
455 bodyCtx, bodyTask := trace.NewTask(s.msgCtx, "DATA")
456 defer bodyTask.End()
457
458 wrapErr := func(err error) error {
459 s.log.Error("DATA error", err, "msg_id", s.msgMeta.ID)
460 return s.endp.wrapErr(s.msgMeta.ID, !s.opts.UTF8, "DATA", err)
461 }
462
463 header, buf, err := s.prepareBody(r)
464 if err != nil {
465 return wrapErr(err)
466 }
467 defer func() {
468 if err := buf.Remove(); err != nil {
469 s.log.Error("failed to remove buffered body", err)
470 }
471
472 // go-smtp will call Reset, but it will call Abort if delivery is non-nil.
473 s.cleanSession()
474 }()
475
476 if err := s.checkRoutingLoops(header); err != nil {
477 return wrapErr(err)
478 }
479
480 if strings.EqualFold(header.Get("TLS-Required"), "No") {
481 s.msgMeta.TLSRequireOverride = true
482 }
483
484 if err := s.delivery.Body(bodyCtx, header, buf); err != nil {
485 return wrapErr(err)
486 }
487
488 if err := s.delivery.Commit(bodyCtx); err != nil {
489 return wrapErr(err)
490 }
491
492 s.log.Msg("accepted", "msg_id", s.msgMeta.ID)
493
494 return nil
495}
496
497type statusWrapper struct {
498 sc smtp.StatusCollector

Callers 3

submitMsgOptsFunction · 0.45

Calls 10

prepareBodyMethod · 0.95
cleanSessionMethod · 0.95
checkRoutingLoopsMethod · 0.95
wrapErrMethod · 0.80
MsgMethod · 0.80
RemoveMethod · 0.65
BodyMethod · 0.65
CommitMethod · 0.65
ErrorMethod · 0.45
GetMethod · 0.45

Tested by 3

submitMsgOptsFunction · 0.36