mailx to external email address

Hi, How can I use "mailx" command to send message to an email address like this?

echo "This email body" | mailx -s "my subject" "email@hostname.com"

There may be some setup required in sendmail or postfix??

OS = Snow Leopard 10.6

Set up a "smart host" in sendmail (usually the same machine as the outbound server in your graphical email client.)
If you do not want to use a smart host, then you will need a static ip, dns and reverse dns for the domain that you are using.

I was able to get the sendmail kind of working.
Using the instructions on this site:
http://yoavgivati.com/2009/10/let-postfix-send-mail-through-your-gmail-account-snow-leopard/

I can send mail from OS X.

Now instead of arriving into the inbox, the email goes into the junk mailbox. Could be because gmail is catching it as spam for some reason.

What do you suggest to get around this issue?

Check all the header records in the mail that arrives in junk. You may find the reason that it is marked junk.
Try sending to a Windows POP client (Outlook Express, Thunderbird) and see if it also goes to junk.

I did try to a different address and it went through ok. Thanks.