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" -> "[email protected]",
 "To" -> "[email protected]",
 "Subject" -> "Example Message",
 "Body" -> "Test",
 "Server" -> "smtpout.secureserver.net",
 "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" 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.

  • $\begingroup$ 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. $\endgroup$
    – Matariki
    Commented Jul 14, 2012 at 6:13

3 Answers 3


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" -> "[email protected]",
 "Subject" -> "Example Message",
 "Body" -> "My text",
 "From" -> "[email protected]",
 "Server" -> "smtp.gmail.com",
 "UserName" -> "[email protected]",
 "Password" -> Automatic,
 "PortNumber" -> 587,
 "EncryptionProtocol" -> "StartTLS"
  • 4
    $\begingroup$ Up voted because today I learned I can automatically email my advisor from within Mathematica. $\endgroup$
    – user1602
    Commented Jul 14, 2012 at 10:17
  • 2
    $\begingroup$ 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. $\endgroup$
    – Jagra
    Commented Jul 14, 2012 at 14:35
  • $\begingroup$ @Jagra I have experienced the same problem with my iCloud account which gives me a cannot connect error. Since I use the gmail account. $\endgroup$
    – Matariki
    Commented Jul 14, 2012 at 20:21
  • 2
    $\begingroup$ 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 post.mathematica.stackexchange.com/questions/67069/… $\endgroup$
    – Brian G
    Commented Jan 15, 2016 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.


I have gotten mail to work through Microsoft Exchange 365 using code similar to the gmail code above.

SendMail["To" -> "[email protected]", 
 "Subject" -> "Example Message via Microsoft", "Body" -> "Keine Fehler!", 
 "From" -> "[email protected]", "Server" -> "outlook.office365.com",
  "UserName" -> "[email protected]", "Password" -> Automatic, 
 "PortNumber" -> 587, "EncryptionProtocol" -> "StartTLS"]

You can include your actual password instead of Automatic for the password field. For some reason, I was not able to get this to work by filling out the server fields in the mail preferences dialog; they need to be specified with each message.

Further, as far as I can tell, Mathematica ignores the "From" and "Full Name" fields. Whatever server I use (gmail, outlook, Wolfram Cloud), it inserts the UserName instead.

  • $\begingroup$ After endless of tries, adding the option "ServerAuthentication" -> True made it possible to send e-mails :) $\endgroup$ Commented May 13, 2017 at 12:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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