Running Wolfram Desktop on Linux with settings

enter image description here

and running

SendMail["[email protected]", "Here is the body of the \

I get either

JavaNew: Incorrect number or type of arguments to constructor for class \
com.wolfram.externalservice.email.SMTP. The arguments, shown here in \
a list, were {smtp \
,Null,imap.gmail.com,25,True,[email protected],$Failed,False,\

or sometimes just a flat out

enter image description here

How do I sync Wolfram up to gmail? Or is there some alternate way of sending emails to a specified email address from Wolfram?


1 Answer 1


Here how to set up Google's outgoing mail (SMTP) server from Google Help. The error shows that you're trying to connect to port 25, and that's the wrong setting.

The first step is to sign in at gmail.com, and check that IMAP is turned on for your account. Sign out of gmail.

Follow the instructions to set the Mail Settings preferences in Mathematica. Enter your password at the Incoming tab.

Added: Google IMAP limits and troubleshooting

As of May 2020, Google limits accounts to 2500 MB per day for IMAP downloads and 500 MB per day for IMAP uploads. Exceeding these limits may cause a temporarily lockout.

There’s a limit of 15 IMAP connections per account. If you use multiple email clients or devices for the same Gmail account, try closing or signing out of some.

The Google Help troubleshooting notes that email applications may try to download too many emails at one time, and recommends:

  • Update Gmail IMAP settings so you don't sync certain folders.
  • In Gmail IMAP settings, set IMAP to only sync folders with 10,000 emails or fewer.
  • Make sure your mail application isn't set to check for new email too frequently. If your mail application checks for new messages more than once every 10 minutes, access to your account could be blocked.


Mathematica doesn't seem to have an preference setting to limit IMAP downloads. Large gmail folders could exceed the daily download limit.

  • 1
    $\begingroup$ I followed the instructions in your link, and it worked for a few SendMail's, until it started to yield this error. $\endgroup$
    – George
    May 7, 2020 at 2:57
  • 1
    $\begingroup$ @George, the error message is cryptic and not helpful. It doesn't indicate anything except that the connection failed. I added some information, and troubleshooting steps from Google. $\endgroup$
    – creidhne
    May 7, 2020 at 14:56
  • 1
    $\begingroup$ I figured out the issue. If I use the MailSettings (described in Wolfram's documentation) to completely specify my email (username, password, SSL preference, etc), then I can send unlimited messages through Wolfram via GMail. $\endgroup$
    – George
    May 7, 2020 at 17:47

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.