Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Email doesnt send if there is one of receipts address invalid #192

Open
shyandsy opened this issue Jan 25, 2024 · 4 comments
Open

Email doesnt send if there is one of receipts address invalid #192

shyandsy opened this issue Jan 25, 2024 · 4 comments

Comments

@shyandsy
Copy link

error: Recipient address rejected

if there is a list of receipts, and one of them is invalid, gomail will abort whole sending process, and it not make sense

func (c *smtpSender) Send(from string, to []string, msg io.WriterTo) error {
	if err := c.Mail(from); err != nil {
		if err == io.EOF {
			// This is probably due to a timeout, so reconnect and try again.
			sc, derr := c.d.Dial()
			if derr == nil {
				if s, ok := sc.(*smtpSender); ok {
					*c = *s
					return c.Send(from, to, msg)
				}
			}
		}
		return err
	}

        // !!!! it doesnt send any email if there is an invalid email address 
	for _, addr := range to {
		if err := c.Rcpt(addr); err != nil {
			return err
		}
	}

	w, err := c.Data()
	if err != nil {
		return err
	}

	if _, err = msg.WriteTo(w); err != nil {
		w.Close()
		return err
	}

	return w.Close()
}
@wneessen
Copy link

This is a know bug but unfortunately won't be fixed since the maintainer has sadly passed away.

You might want to consider checking wneessen/go-mail which has addressed this issue and has dedicated error detection for failed bulk mails.

@shyandsy
Copy link
Author

shyandsy commented Feb 14, 2024 via email

@wneessen
Copy link

I am not the maintainer of this repository. As mentioned, the maintainer passed away and and PR won't be accepted anymore.

@shyandsy
Copy link
Author

shyandsy commented Feb 16, 2024 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants