(ctx context.Context, rcptTo string, _ smtp.RcptOptions)
| 61 | } |
| 62 | |
| 63 | func (d *delivery) AddRcpt(ctx context.Context, rcptTo string, _ smtp.RcptOptions) error { |
| 64 | defer trace.StartRegion(ctx, "sql/AddRcpt").End() |
| 65 | |
| 66 | accountName, err := d.store.deliveryNormalize(ctx, rcptTo) |
| 67 | if err != nil { |
| 68 | return userDoesNotExist(err) |
| 69 | } |
| 70 | |
| 71 | if _, ok := d.addedRcpts[accountName]; ok { |
| 72 | return nil |
| 73 | } |
| 74 | |
| 75 | // This header is added to the message only for that recipient. |
| 76 | // go-imap-sql does certain optimizations to store the message |
| 77 | // with small amount of per-recipient data in a efficient way. |
| 78 | userHeader := textproto.Header{} |
| 79 | userHeader.Add("Delivered-To", accountName) |
| 80 | |
| 81 | if err := d.d.AddRcpt(accountName, userHeader); err != nil { |
| 82 | if errors.Is(err, imapsql.ErrUserDoesntExists) || errors.Is(err, backend.ErrNoSuchMailbox) { |
| 83 | return userDoesNotExist(err) |
| 84 | } |
| 85 | var serializationError imapsql.SerializationError |
| 86 | if errors.As(err, &serializationError) { |
| 87 | return &exterrors.SMTPError{ |
| 88 | Code: 453, |
| 89 | EnhancedCode: exterrors.EnhancedCode{4, 3, 2}, |
| 90 | Message: "Internal server error, try again later", |
| 91 | TargetName: "imapsql", |
| 92 | Err: err, |
| 93 | } |
| 94 | } |
| 95 | return err |
| 96 | } |
| 97 | |
| 98 | d.addedRcpts[accountName] = addedRcpt{ |
| 99 | rcptTo: rcptTo, |
| 100 | } |
| 101 | return nil |
| 102 | } |
| 103 | |
| 104 | func (d *delivery) Body(ctx context.Context, header textproto.Header, body buffer.Buffer) error { |
| 105 | defer trace.StartRegion(ctx, "sql/Body").End() |
nothing calls this directly
no test coverage detected