Closed srivathsanmurali closed 5 years ago
This is still a WIP. I thougth I would send in the PR to see what you think about this approach to the problem as I continue to work on this. I am currently building a elixir service that needs a SMTP client and this works really well.
I hope I contribute to your project :smile:
I am working to update the tests to use the new SMTP/Email methods I implemetented in this PR.
Cheers
This PR is ready to be reviewed. This branch is based on the branch used in #3, I will rebase this PR based on how #3 goes.
I am willing to help further with the SMTP Module specifically if you require more help.
Rather than handling this within Mailroom, I’ve been working extensively with the Dockyard/elixir-mail project which already does structured mail parsing and encoding.
It is already included as a dependency (as :mail
)
Sweet, didn't notice that. Alright. I think I will close this PR.
@andrewtimberlake I wonder if handling multiple recipients be inline with the objectives of the :mailroom package.
Would it make sense for me to rework this PR to expose an function that takes an %Mail.Message{} as an argument which would help in sending RCPT
commands for each of the recipients and use Mail.Renders for encoding the message.
Which recipients would you send? When sending a message with multiple recipients (to, cc, bcc), each of them might need to go to a different SMTP server.
I am new to the mail processing and I may have misunderstood but this is my understanding.
Which would mean, this module that acts the SMTP client doesn't need to worry sending to different SMTP servers.
When you send an email to: bob@google.com and cc: john@facebook.com, both of those domains will have a different receiving SMTP server.
The process would be
Often you will use a relay SMTP server (such as from your ISP). This server will accept any RCPT TO (usually after AUTH) and it will perform the above steps on your behalf.
I’m happy to work on a send
command that takes a %Mail.Message{}
and sends to all recipients but we need to make sure we handle situations where the SMTP server rejects some or all of the recipients.
Thanks for clarification.
I had implemented the send method just as you described just a bit earlier. https://github.com/srivathsanmurali/mailroom/blob/multiple_recipients_email/lib/mailroom/smtp.ex#L242
I will work on the error handling for the case when SMTP servers reject on some/all recipients.
This PR goes after #3. A new Email module is implemented that makes it easier to create new emails in a structured manner and send via SMTP.
This also makes it easier to add some add check email fields.