Some time ago, @marc005 asked how he could send an email from the Maple command line.
Why would you want to do this? Using Maple's functionality, you could programatically construct an email - perhaps with the results of a computation - and email it yourself or someone else.
I originally posted a solution that involved communicating with a locally-installed SMTP server using the Sockets package. But of course, you need to set up an SMTP server and ensure the appropriate ports are open.
I recently found a better solution. Mailgun (http://mailgun.com) is a free email delivery service with an web-based API. You can communicate with this API via the URL package; simply send Mailgun a URL:-Post() message that contains account-specific information, and the text of your email.
The general steps and Maple commands are given below, and you can download the worksheet here.
Note: Maplesoft have no affiliation with Mailgun.
Sign up for a free Mailgun account.
In your Mailgun account, go to the Domains section - it should look like the screengrab below (account-specific information has been blanked).
Note down the API Base URL and the API key.
- the API Base URL looks like https://api.mailgun.net/v3/sandboxXXXXXXXXXXXXXXXXXXXXXXXXXXX.mailgun.org.
- the API Key looks like key-XXXXXXXXXXXXXXXXXXXXXXXXXX
In Maple, define strings containing your own API Base URL and API Key. Also, define the recipient's email address, the email you want the recipient to reply to, the email subject and email body.
>APIBaseURL := "https://api.mailgun.net/v3/sandboxXXXXXXXXXXXXXXXXXXXXXXXX.mailgun.org":
>toEmail := "email@example.com":
>fromEmail:="First Last <FirstLast@Domain.com>":
>subject:= "Email Subject Goes Here":
>emailBody := "I'd rather have a bottle in front of me than a frontal lobotomy":
Run the following code
If you've successfully sent the email, you should see something like this (account-specific information is blanked out)
You can also send HTML emails by replacing the "text" line with "html" = str, where str is a string with your HTML code.