| 508 | } |
| 509 | |
| 510 | func (s *SMTPHandler) validateToAddrs(to string) ([]string, error) { |
| 511 | addrs, err := mail.ParseAddressList(to) |
| 512 | if err != nil { |
| 513 | return nil, xerrors.Errorf("parse 'to' addresses: %w", err) |
| 514 | } |
| 515 | if len(addrs) == 0 { |
| 516 | s.log.Warn(context.Background(), "no valid 'to' address(es) defined; some may be invalid", slog.F("defined", to)) |
| 517 | return nil, ErrValidationNoToAddress |
| 518 | } |
| 519 | |
| 520 | var out []string |
| 521 | for _, addr := range addrs { |
| 522 | out = append(out, addr.Address) |
| 523 | } |
| 524 | |
| 525 | return out, nil |
| 526 | } |
| 527 | |
| 528 | // smarthost retrieves the host/port defined and validates them. |
| 529 | // Does not allow overriding. |