I need to send mail form shell script with Snow Leopard local postfix, but it doesn't work

echo "`whoami` login, `date`" | mail -s "test" admin@gmail.com
link|improve this question
1  
It helps if you're more specific than "it doesn't work". What error messages do you get? What do the logs say? – Dennis Williamson Dec 26 '09 at 15:54
feedback

migrated from stackoverflow.com Dec 27 '09 at 6:31

This question came from our site for professional and enthusiast programmers.

4 Answers

Have you started postfix?

# sudo postfix start

I believe...

link|improve this answer
feedback

I have successfully used msmtp on Leopard and Snow Leopard and I highly recommend it.

msmtp is an SMTP client.

In the default mode, it transmits a mail to an SMTP server (for example at a free mail provider) which does the delivery. To use this program with your mail user agent (MUA), create a configuration file with your mail account(s) and tell your MUA to call msmtp instead of /usr/sbin/sendmail.

It's not a smtp server but does the job well from a script if you have an ISP to relay your emails from.

link|improve this answer
1  
Thanks! Installing msmtp is much easier than enabling Postfix. I just create a ~/.msmtprc and a ~/.mailrc containing: set sendmail=/usr/local/bin/msmtp – Dexter.Yy Dec 26 '09 at 18:29
feedback

A local default Postfix configuration on Mac OS X (not Server) will be flagged as spam by many receiving SMTP servers (eg. GMails) because of either PBL from Spamhaus or that it's very obvious that the email is not from a valid location (by spam standards). You need to edit the configuration for Postfix to use your local ISPs (or someone else's) mail server to send correctly.

Specifically you're looking for manipulating the 'relayhost' value in your Postfix config.

link|improve this answer
feedback

As Oscar suggested, verify that postfix starts automatically -- but rather than using sudo postfix start, do it in a more mac-like way. You'll want to edit /System/Library/LaunchDaemons/org.postfix.master.plist. There's a nice writeup in this blog post.

If that still doesn't work, your ISP might be blocking outbound smtp traffic. See an answer I gave on a related question for ways around that.

link|improve this answer
feedback

Your Answer

 
or
required, but never shown