macOS send email on boot?

Can someone tell me how to have macOS automatically send me an email when it boots up?

A link or instructions would be great!

Thanks,
Dave

I think it’s unlikely to be possible: from which account on the Mac would it be sent?

Keyboard Maestro has the ability to trigger a macro on login, however, and that macro could certainly send an email. Obviously, if you are automatically logged in on startup, that would do what you want.

Jeremy

Depending on your level of expertise “under the hood” you could likely use Outset to implement something.

I was just playing with automator.app today, you could probably create a workflow to send yourself an email, save it as an application, and add that application to your login items.

The orginal question was about boot, not login. Maybe they meant login. Or not.

If boot you need a way to do it before anyone has logged in.

I think a lot of Mac users at home have a single user account and have the account automatically login so using the user’s login items is basically equivalent to running something at boot.

The easiest way I know to send an email at actual boot, not user login, is to use cron to run a command line script. Cron is the venerable Unix utility for running commands on a scheduled basis (every hour, every other day, every third Monday, etc.) but even amongst people who have used it, many don’t know that it includes a @reboot nickname for running commands at boot. Edit the current user’s “crontab” by running crontab -e in Terminal which will open your text editor (I think it’s vi by default), insert a new line like this: @reboot /path/to/script.sh. After you’ve saved the change, use crontab -l to list your current cron jobs.

Note: if you have FileVault enabled, macOS does not boot when you turn your Mac on so nothing can run until someone logs in at the FileVault login window. Also, if your Mac is only on WiFi, I don’t know when (or if) your Mac has a working network connection; if it eventually gets on WiFi but not in time, you could add something like sleep 60 to your shell script to make it wait 60 seconds before running the rest of the script.

The more difficult, user-specific challenge is not the automation part, it’s sending the email from the command line at all. Your script to send an email needs an SMTP server to accept it and mail servers have become much more cautious than they used to be. Many solutions found on the web are either old and no longer work as-is or involve having an email password saved in a plain text file which is risky (maybe not, if you create an email account just for sending these emails).

I do exactly this on my Mac mini, and have for many years. It was a very simple Automator application that runs on login. However, I do have the Mac Mini set to automatically log in to an account on boot.

The Automator script is only three steps - Pause for 120 seconds; New mail message with the message filled out; then Send outgoing messages.

But, as others have said, this requires automatic log in to an account on restart.

Would you be willing to share your script?

Thanks,
Dave

I really can’t unless you want to send me an email every time you log in. But, I can tell you how to recreate it for yourself.

  1. Open the Automator app. Click File / New.
  2. Click “Application” as your type of document and click the “Choose” button.
  3. Type “Pause” in the search box in the middle column. Drag the “Pause” action to the pane on the right, and enter “120” for the pause value. (This may be optional, but back when I created this - on a 2007 Mac mini - that was a safe amount of time for the log in process to have finished loading. It was so long ago that I don’t remember if I needed this because it didn’t work without it, or if I just guessed that I did and was fine with a 2 minute delay.)

  1. Search for “Mail” in the middle pane. Drag “New Mail Message” to the right pane, below the Pause action. Enter the details for address to send, message subject, message text, and optionally choose which account that you want to use in the bottom “Account” section.

  2. Now drag the item “Send Outgoing Messages” below the “New Mail Message” action.

  1. Then it’s time to File / Save, give the application a name, and save it in the “Applications” folder.

2 Likes