Thursday 4 June 2020

How to send mail from Linux system

Use the below command to send mail from a Linux server to a user email-id:

# echo "this is the body of the email" | mailx -s "test mail" -r "From" -S smtp="your-smtp"

-s =         Specifies the subject.
-r =         Email sent from.
-S =        Specifies the smtp server.

We can also add the configuration in mailx config file  /etc/mail.rc

set smtp=your.smtp.server

set from="from email address"

Then run the mailx command and then enter the body of the email, hit enter, and finally press Ctrl+D to deliver it.

# mailx -vvv -s "email subject"  external-email-address

<Body of the email>

Ctrl D to deliver the message

No comments:

Post a Comment

Was this Post Helpful?

Feel free to suggest your opinions in the comments section!