Mail does not work in scripts launched with launchd 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?
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.