Sending Mail from a locked Mac?

Define latest - I’m still on Mojave :wink:

I fear when I read “Private API”… it looks suspicious to my mind (Man in black…) :rage:

The latest documentation for the system that you’re running.

Interesting, I’ve never encountered this, but it sounds like what may be happening.

  • is it when the Screen is locked or when the Keychain is locked (is this the same thing?)
  • is your app fully code-signed and notarized? (I believe non-signed apps are blocked from doing some HTTP requests by default…)
  • does wrapping your email sending routine in calls to NSProcessInfo beginActivity and endAcitivity help? See Monkeybread Xojo plugin - NSProcessInfoMBS methods

Hi Sam and everyone :slight_smile:

Great to see the activity here!

I’m leaning toward just trying a method to turn on the Mac in a small window around the time the message sends. Want to keep it as simple as possible!

Thanks!

Nydhogg

1 Like

Some sites that might be helpful:

Send email via terminal
https://betterprogramming.pub/how-to-send-mail-from-the-macos-terminal-dad1756b166f

Scheduling Jobs With Crontab on macOS (note that you need to give cron access - this is new since Mojave):

https://medium.com/macoclock/automate-running-a-script-using-crontab-on-macos-88a378e0aeac

https://betterprogramming.pub/https-medium-com-ratik96-scheduling-jobs-with-crontab-on-macos-add5a8b26c30

crontab guru: Cron examples - Crontab.guru

Note that (as you can only specify a time range in the 0-23 hour range) you will need TWO cron jobs: one for every hour BEFORE midnight, one for every hour AFTER midnight

In the script that cron executes

– send mail

  • get the current time
  • create a newtime that is 1 hour later
  • set the power manager to wake later: pmset repeat wakeorpoweron MTWRFSU newtime
  • put the computer back to sleep

Note: you could also convert your scripts to launchd tasks rather than cron entries.

2 Likes