Problem
I would like to be able to send an email from the command line on a system that is configured with the sendmail MTA. Is there a simple way to do this?
Solution
It is possible to send an email from the command line in OpenServer 6.0.0 using sendmail.
NOTE: This article assumes that sendmail has been correctly configured
to send local and non-local email.You can send a file you have previously created as email using
# cat foobar.txt | /usr/lib/sendmail recipient@domainwhere:foobar.txt is the file you want to send as an email and recipient@domain is the recipient of the email
Please note that by default the file will be sent from your username@server_domain where
username is the user you are logged into the server as
andserver_domain is domain of the serverPlease note that in foobar.txt you can define email header items such as:
Subject: <The usual subject of the email>andTo: <recipient@domain>You can also change who the email comes from using:
# cat foobar.txt | /usr/lib/sendmail -f username@domain recipient@domain See also
TA#125337: "I want to create a script or use the command line to send an email with an attachment non-interactively, how can I do this?"