Mathematica Stack Exchange is a question and answer site for users of Mathematica. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I can't get my email settings set properly such that I can use SendMail[] to email directly from Mathematica.

I have opened "Preferences", clicked on the tab "Internet Connectivity" and filled in all the settings to match those in my Apple Mail accounts settings.

These include:

  • Server
  • Port Number
  • Encryption Protocol
  • Username
  • From Address
  • Full Name
  • Reply To

Odd that no setting exists for "Password"?

The "Preference" window's "Test Internet Connectivity" tells me "Test succeeded..."

Apple Mail has a setting to "Use default ports (25, 465, 587)" so I thought this might confuse the Mathematica settings, so I've tried setting the Apple Mail settings to "Use Custom Port" and specified each of the the default ports specifically. None of those settings worked either.

I have also attempted to specify all available options for SendMail[] specifically also trying each of the 3 possible "default" ports described above.

 "From" -> "",
 "To" -> "",
 "Subject" -> "Example Message",
 "Body" -> "Test",
 "Server" -> "",
 "EncryptionProtocol" -> "SSL",
 "FullName" -> "MyUserName",
 "Password" -> "myPassword",
 "PortNumber" -> 25 (* I also tried 465, 587 *),
 "ReplyTo" -> None,
 "ServerAuthentication" -> Automatic,
 "UserName" -> "myUserName"

Again SendMail[] gives me the same message: $Failed.

Also, in the "Preferences" window under the "Proxy Settings" tab I have tried selecting both "User proxy settings from my system or browser" and "Direct connection to the Internet".

The "Troubleshooting Internet Connectivity Problems - Wolfram Mathematica" in the "Document Center" suggests checking proxy settings. Given what mine look like in Snow Leopard's "Preferences" >> "Network" >> "Proxies"


I don't think I have much to help.

I have no Firewall Setting on the computer.

This has me stumped.

Does anyone have an idea of what else I can try.

share|improve this question
It works for me on a mac using a gmail account but not using my icloud account. See if you can get it to work using another email server. – Matariki Jul 14 '12 at 6:13
up vote 22 down vote accepted

This might not work for you but is an example to use the Gmail mail server to send emails from a notebook.

The example code overrides all settings in the MMa email preference settings and should work out of the box. NB I have tested this only on my Mac.

 "To" -> "",
 "Subject" -> "Example Message",
 "Body" -> "My text",
 "From" -> "",
 "Server" -> "",
 "UserName" -> "",
 "Password" -> Automatic,
 "PortNumber" -> 587,
 "EncryptionProtocol" -> "StartTLS"
share|improve this answer
Up voted because today I learned I can automatically email my advisor from within Mathematica. – user1602 Jul 14 '12 at 10:17
I set up a gmail account and your solution works perfectly. Odd that I couldn't get this to work with any of my other email accounts. My browser, Safari, easily sends emails from my main email account. It seems like that should work with Mathematica. In any event, thanks. – Jagra Jul 14 '12 at 14:35
@Jagra I have experienced the same problem with my iCloud account which gives me a cannot connect error. Since I use the gmail account. – Matariki Jul 14 '12 at 20:21
Gmail has updated their security policy so if you're trying to make this work you'll also have to allow "less secure apps." When I set it up and tried it the first time it was blocked and I received a warning email. Following the link in the warning email, I opted to allow less secure apps to access my account and the emails then sent. Here is a related… – Brian G Jan 15 at 5:43

The challenge with SendMail is that you the Mathematica user must attempt to make the ISP mail server happy. For example, Matariki’s above Gmail solution depends on properly setting up Allowing less secure apps to access your account. An email delivery service such as Mailgun offers a simpler solution, see my Wolfram Community post Simple inexpensive delivery service outperforms SendMail. The posted example calls CloudDeploy, but you would just be calling the enclosed URLExecute directly from Mathematica.

share|improve this answer
Thanks for this contribution. – Jagra Mar 31 '15 at 13:37

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.