How do I send email with sendmail to external hosts?

Posted by Jake on Server Fault See other posts from Server Fault or by Jake
Published on 2012-11-06T19:52:28Z Indexed on 2012/11/07 11:06 UTC
Read the original article Hit count: 353

Filed under:
|

If I wanted to send an email to a user on the same linux machine, I can run:

echo -e "Subject: Foo\n\nBar\n" | sendmail -v jacob

But if I run:

 echo -e "Subject: Foo\n\nBar\n" | sendmail -v [email protected]

It will give me the error:

050 >>> MAIL From:<jacob@mu> SIZE=321
050 550 5.1.8 Cannot resolve your domain {mx-us011}

If my machine has access to the internet but is behind a router and has no domain associated with it, can I use sendmail to send mail to this address?

Do I need to connect through an SMTP server?

Can I do that with sendmail?

If I use sendmail's -f option and put my gmail account there it will work. Can (or should I) I use my IP address?

echo -e "Subject: Foo\n\nBar\n" | sendmail -v -f [email protected] [email protected]

I'm a bit lost on how all this comes together in sending mail from the command line.

© Server Fault or respective owner

Related posts about command-line

Related posts about sendmail