SMTP from one address to another address failing
First off, thank you for putting this together!
I'm having trouble with sending email from one address to another. I am using the docker image.
I have followed the readme and made a template with the From: line modified to From: {{env "EMAIL_FROM"}} where $EMAIL_FROM is an env var available to said docker image.
It does work when the from/to email address is the same (e.g., emailing yourself) - but I get recipient=<EMAIL_TO> method=smtp error="550 Request failed; Mailbox unavailable" when going from one address to another.
I see https://github.com/skx/rss2email/issues/79 notes that the issue regressed. Maybe that is why?
I also do see that https://github.com/skx/rss2email/blob/master/processor/emailer/emailer.go#L382 has err := smtp.SendMail(addr, auth, to, []string{to}, content) which I read as that the from and to are indeed one and the same to and so cannot email from one address to another. (nb: I do not know go, but the []string{to} really looks like it's just doing operations on the var to)
Let me know if I'm missing something, this looks perfect for me and I am hoping to get it to work!
It does seem like a bug, but I wonder if there's a simple solution. You mention using the $EMAIL_FROM value in the template - coming from the environment.
It seems to me that you could set the two auth-related values to sidestep the issue:
- SMTP_USERNAME would be the email of the sender/from
- SMTP_PASSWORD would be the password for that user.
Setting those two values and updating the template to match seems like it should let you use "any" sender address - and of course the recipient would then be specified on the command line and could/would be different.
Am I missing something here?
Thanks for responding so quickly!
I've got SMTP_USERNAME: [email protected] and I've got SMTP_PASSWORD: [email protected], I'm starting the container with
command: daemon -verbose [email protected]
entrypoint: rss2email
and for the custom template, instead of hardcoding an email I just set it to the env var $EMAIL_FROM that I give to the docker container - hardcoding it doesn't change anything there.
I get the [email protected] method=smtp error="550 Request failed; Mailbox unavailable" until I set
command: daemon -verbose [email protected]
entrypoint: rss2email
and then it works.
There's no more information about the error in the logs (e.g., what email it tried to send from), but I'm guessing from the source code that maybe it's trying to use the [email protected] instead of the [email protected] to when it tries to send the email, and the SMTP server wigs out because the credentials aren't legit (or the receiving server wigs out because they're not legit, idk).
Like what has me thinking this, the go example:
to := []string{"[email protected]"}
msg := []byte("To: [email protected]\r\n" +
"Subject: discount Gophers!\r\n" +
"\r\n" +
"This is the email body.\r\n")
err := smtp.SendMail("mail.example.com:25", auth, "[email protected]", to, msg)
has [email protected] in the 3rd slot with [email protected] in the 4th slot.
But the emailer.go source has
// Send the mail
err := smtp.SendMail(addr, auth, to, []string{to}, content)
where both the [email protected] in the 3rd and 4th slots. So the SMTP authentication before this line worked with the user/pass and all - but the sending breaks because the email is generated incorrectly saying that the [email protected] email sent the email to itself at [email protected]. And something along the way catches it and rejects it.
But if I email myself, so from and to are ==, everything is above board to the email servers and it works.
Lemme know if that makes sense!