How can I send smtp mail via gmail and osx Lion mailx? I would like to be able to send email from utility/batch/launchd scripts via my gmail account and the mailx client that is bundled in OS X Lion. I cannot find how to configure this. I found http://www.andrews-corner.org/mutt.html#sending which describes doing this for mutt, but I'd rather not have to install mutt. I do have Thunderbird installed and use that to read/send mail (instead of Mail.app).

When I run 
   mailx -v -s subject myemailaddress@gmail.com &lt; file.txt
I get no errors, but instead of getting an SMTP transaction log, mailx tells me 

Mail Delivery Status Report will be mailed to &lt;David&gt;.


Worse, there is no /var/mail/David folder, so this report appears to go into a bitbucket.
One way to fix this is to install the official server app in order to re-enable this feature.  You don't have to setup a mail server through the app.  Just installing it will allow use of mailx through the command line.

In the past, you had to buy and install OS X server as a separate product and now it's available from the App Store and gets installed on top of the normal OS.