Message Boards Message Boards

Send email with SendMail or an external delivery service?

8 Replies

I'm working in an implementation of Mailgun API for Mathematica. Just to leave a note for future readers, I discovered that Base64 are not supported in Gmail and Outlook, as you can check here.

POSTED BY: Rodrigo Murta

Pieter van Bijnen points out the importance of sending email in HTML format and including inline images. Accordingly, I’ve updated the code in my original post to demonstrate such an email.

Also, don’t delay setting up your own email domain. The code in my original post sends an email from the Mailgun sandbox domain. But all your test, development, and production code should send email from your own domain. Domain setup consists of two simple steps. First, generate DNS zone file TXT, CNAME, and MX records: login to Mailgun (or whichever email delivery service you’ve chosen), follow the link to add a new domain, and enter a subdomain name. Second, enter these records into the DNS zone file for your domain: login to your domain hosting account and follow the appropriate links to add zone file records. Other than entering these records, subdomain setup does not involve any other actions on the domain hosting account. If you’re building applications that do both bulk marketing and transactional email, then keep their email reputations separate by setting up different email domains for each.

Posted 9 years ago

If it is better, why wouldn't SendMail[] be modified to work like this?

POSTED BY: Sandu Ursu

Whether it's better to use SendMail or an email delivery service will depend on your application. Right now the delivery service is likely the only solution if you need to send thousands of emails per month, anticipate even higher future volumes, and want to send from your own domain to many different destination email addresses. I heartily agree with your suggestion to enhance SendMail. Indeed there could be quite an opportunity for a strategic alliance between Wolfram Research and an email delivery service provider: Wolfram would gain highly specialized expertise in delivering email against the ever evolving background of spammers and countermeasures. The delivery service provider might gain a lot of new users from Mathematica and Wolfram Cloud applications.

Christopher,
I have tested your mail solution and it works. Then I went on trying to add "inline" html image and "attachments". Both need to be formatted like inline="@files/filename.jpg" or attachments="@files/filename.jpg". The "inline" must be very easy. I suspect the "attachment" is probably a little more difficult because it needs multipart/form-data.

in urlfetch i found "MultipartElements" -> {{"partName", "mime/type", {1, 2, 3, 4, 5}}}

can you help me solve how to do this?

Yes, all mail services will handle HTML formatted email. For a simple Mailgun example see Manual > Sending Messages > Sending via API. The example cURL HTML string is added to the MultipartElements option of the Wolfram Language URLFetch. Preserve and enhance the reputation of your domain (and IP address) by sending both text and HTML or text only, see Email Best Practices > Email Content.

Christopher, thanks for sharing. If I am not mistaken this adds html formatted mail.

Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract