email: fix empty emails sent on retries
io.Reader objects can only be consumed once. On retry, re-reading from
them will return 0 bytes all the time.
Change NewTask to take in a bytes array instead of a reader. Create
a new reader on each retry.
Also remove SendRaw which has an inherent issue related to retry as
well. message.Entity is virtually a reader that can only be consumed
once.
Update EnqueueRaw to take a bytes array directly and have it call
NewTask() like EnqueueStd does.
Fixes: 78cfc5d87a7d ("email: allow sending raw emails")
Signed-off-by: Robin Jarry <robin@jarry.cc>
email: allow sending raw emails
The current email.Enqueue() function only allows sending messages with
the server's default settings.
In order to support sending any arbitrary message, we need to expose
a lower level API taking a raw message.Entity pointer. This new API will
be reused in a future reimplementation of the lists.sr.ht ingress agent
to forward messages to subscribers.
Add email.EnqueueRaw() that calls email.SendRaw(). Retry sending 10
times in the case of failure.
Signed-off-by: Robin Jarry <robin@jarry.cc>
email: keep smtp client connection alive
Instead of connecting and disconnecting each and every time we need to
send an email, keep the SMTP connection alive attached to a context
variable.
Before sending an email, check if the connection is still valid and
reconnect if it is not.
Signed-off-by: Robin Jarry <robin@jarry.cc>
email: update StartTLS usage per go-smtp changes
Bugfix, mail config placed in wrong setting.
Add support for mail setups that don't support TLS or Auth
email: remove leftover debug code