2

I'm using this setup to be able to send mail from Terminal: http://www.anujgakhar.com/2011/12/09/using-macosx-lion-command-line-mail-with-gmail-as-smtp/

It works great, and I can use it in scripts. As long as I run the script manually.

However when the script is launched by launchd, no mails are ever sent off.

Looking around, it seems that this could be related to AbandonProcessGroup, which I didn't specify in the launchd job first.

https://superuser.com/questions/281537/using-launchd-for-short-non-daemon-tasks

However, despite setting AbandonProcessGroup to true, mails are still never sent off. I can't find any error message in log (or I'm looking at the wrong place). How to fix this?

Update 2022-12-27

I'm gonna include the original setup from anujgakhar.com here in case that site goes away.

# Configure Postfix for Gmail SMTP
Edit file /etc/postfix/main.cf
[xml]
sudo vim /etc/postfix/main.cf[/xml]

# and add in the following below the commented out relayhosts :-

[xml]
relayhost = [smtp.gmail.com]:587
smtp_sasl_auth_enable = yes
smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd
smtp_sasl_security_options = noanonymous
smtp_use_tls = yes
[/xml]

# Generate sasl_password if not already exists
[xml]
sudo vim /etc/postfix/sasl_passwd
[/xml]

# and enter in the following:-
[xml]
[smtp.gmail.com]:587 [email protected]:password
[/xml]

# Run the following commands
[xml]
sudo chmod 600 /etc/postfix/sasl_passwd
sudo postmap /etc/postfix/sasl_passwd
sudo launchctl stop org.postfix.master
sudo launchctl start org.postfix.master
[/xml]
1
  • Make your comment=solution as an answer please for others to find.
    – Ruskes
    May 27, 2013 at 7:15

1 Answer 1

7

Not sure what happened here, but I got it working now. AbandonProcessGroup definitely needs to be set to true. Also make sure no other errors exist. I had some error, and after clearing that out things started working. It helps by specifying log output files in the launchd jobs. Use StandardOutPath key for log output, and StandardErrorPath key for error output. I specified separate files for error and log output.

2

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .