Sometimes Mathematica takes quite a while to finish calculations and it would be convenient to be able to move away from the computer while it is working. I was wondering if there is any "clever" hack that can be used purely within Mathematica to e-mail updates on the computation.

I can think of a very rough way of getting an update other than actually accessing the machine, which would be by exporting some output to a file in Dropbox. From another machine connected to Dropbox I could see when the file is updated. But this seems to me like a very ugly solution.

A less ugly solution would be to write an external script, probably with python, and then have Mathematica run it at some point in the calculation. This would allow for both e-mail and text message updates (using Skype or a similar service and the appropiate python modules).

Is there any way to do something similar purely within Mathematica?

  • 2
    $\begingroup$ SendMail is the API supported by M but you need to find one open SMTP server to send your mail. Internet is full of these, if you know how to find. $\endgroup$ Aug 9, 2013 at 18:59
  • $\begingroup$ related $\endgroup$
    – cormullion
    Aug 9, 2013 at 18:59
  • $\begingroup$ There are services with which you can easily send text messages. They use REST APIs so you can interact with them using for example URLFetch. $\endgroup$
    – C. E.
    Aug 9, 2013 at 19:07
  • $\begingroup$ An even better idea is if these computations take awhile schedule them for when you are drinking beer :) So don;t even bother starting them and then moving away from computer. Combine ScheduleTask and friends with some of the email solutions you get below. For scheduling when Mathematica is not already running here is an example (that can also be combined with email): library.wolfram.com/infocenter/MathSource/7590. So you are out having a beer and u get a message saying computation done. Maybe even an attachment of a plot. $\endgroup$ Aug 9, 2013 at 21:39

4 Answers 4


I like to use the docked cells for this purpose. I create two buttons in my "heavy processing" notebooks:

enter image description here

  • the first is a bell that rings thrice when the computation is finished — used to alert me when I'm at my computer, but doing something else.

  • the second is to send an email to myself when the processing is finished – used when I'm away from my computer, but online (on iPad or a different machine)

Both of them are Buttons with a queued evaluation, so as to prevent the front end from evaluating it pre-emptively (i.e., it will evaluate only after the processing is finished).

You use these buttons by first evaluating (ShiftEnter) all the cells that you want processed and then click the desired button and walk away.

The code for this is below:

    bell = Import["http://upload.wikimedia.org/wikipedia/commons/thumb/b/b3/Bell_alt_font_awesome.svg/200px-Bell_alt_font_awesome.svg.png"], 
    email = Import["http://upload.wikimedia.org/wikipedia/commons/thumb/d/df/Aiga_mail.svg/200px-Aiga_mail.svg.png"], 
    ir = ImageResize[#, {16, 16}] &},

        DockedCells -> Cell[BoxData@ToBoxes@Row[{
               Do[EmitSound[Sound[SoundNote[]]]; Pause[0.5], {3}], 
               Method -> "Queued", Appearance -> "Palette"],
                    "From" -> "[email protected]", 
                    "To" -> "[email protected]", 
                    "Subject" -> "Finished processing!", "Body" -> "", 
                    "Server" -> "mail.domain.com"
                Method -> "Queued", Appearance -> "Palette"]

Use additional options to SendMail as necessary, depending on your email provider.

  • 1
    $\begingroup$ Could also set $Post to get feedback at every output as in $Post = (Do[EmitSound[Sound[SoundNote[]]]; Pause[0.5], {3}]; #) &; $\endgroup$ Aug 9, 2013 at 19:59
  • 3
    $\begingroup$ I can't believe you missed hitting 200 "yesterday" with an answer like this. +1 for today. $\endgroup$
    – Mr.Wizard
    Aug 10, 2013 at 0:34
  • $\begingroup$ @Mr.Wizard Thanks :) $\endgroup$
    – rm -rf
    Aug 10, 2013 at 0:35
  • $\begingroup$ Neat answer, recently linked. +1 $\endgroup$
    – ciao
    Mar 31, 2014 at 1:09
  • $\begingroup$ Can somebody explain me what is to be done with the code above in order to have this work? $\endgroup$ Feb 24, 2016 at 10:10

As stated in this answer you can do the following to send an email form Mathematica. Because of the nature of how email servers are set up you will have to have some server that sends the email.

 "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"

Depending on what type of service you are on you should be able to send text messages through your email by appending @emailprovider.com

For example:

US Cellular: email.uscc.net
Verizon: vtext.com
Virgin: vmobl.com
AT&T: txt.att.net
Nextel: messaging.nextel.com
Sprint: messaging.sprintpcs.com
T-Mobile: tmomail.net

Read more: How to Send a Text Message from Email



If you want results emailed then why not combine that with scheduling of the job? So in other words if you have computations that take awhile or you run regularly why hang around or why even be there to get them started?

More efficient use of time is to schedule the job and go and do something else. Have the job run while you are sleeping and get the results emailed and check on your phone when you wake up.

Create a *.m file containing code like this:

p1 = Plot[Sin[x], {x, -Pi, Pi}];
Export["result plot.png", p1];
SendMail["From" -> "[email protected]", 
  "To" -> "[email protected]", "ReplyTo" -> "", 
  "Subject" -> "How is the beer?", 
  "Body" -> "Here are the results of your scheduled task", 
  "Password" -> "xxxxx", "EncryptionProtocol" -> "SSL", 
  "PortNumber" -> 465, "Server" -> "smtp.gravity.com", 
  "Attachments" -> {"result plot.png"}];

and call it task.m and then run this file at a scheduled time (i.e. some time after beer o'clock)

RunScheduledTask[<< "task.m", {1}, AbsoluteTime[{2013, 8, 10, 17, 27, 0}]]

ScheduledTask and co requires Mathematica to be running but you can also use your systems scheduler to switch Mathematica on and off. Here is how to do it on Macs as of about 3.5 years ago (it may need updating)


If you want to get a text message on your cellphone when the calculation is done, you need a little bit more structure than what Mathematica has built in, but it's not too hard to do.

I use IFTTT - "if this, then that", pronounced ift as in 'gift'. It's a free service which can do all sorts of things, to turn one sort of 'trigger' into an action on some other channel. It's quite easy to make a 'recipe' like this:

enter image description here

Arrange for Mathematica to send an email (using one of the multiple fine answers in this thread) to [email protected] that contains the hashtag text "#Mathematica" in the subject line. (Make sure the "From" in your SendMail agrees with what you declare to ifttt, too.) You can then arrange for ifttt to send a text message to your phone with a bunch of information pulled from the email:

enter image description here

To be honest I haven't used this in a while but I have a feeling I'll be using it again soon enough. Full disclaimer: I am not in any way associated with ifttt - I just find it useful. I'm pretty sure there are other ways of sending SMS through online APIs that can be accessed either directly or through e.g. Python scripts, but this one is fairly simple.


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.