Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to send a html email with the bash command "sendmail"?

Tags:

linux

sendmail

Anyone has a demo available?

Sendmail is said to be not scalable,but it's free,so I decided to use it first for now:)

like image 455
omg Avatar asked Aug 26 '09 08:08

omg


People also ask

How do I send an email using sendmail?

Once logged in, you can run the following command to send email: [server]$ /usr/sbin/sendmail [email protected] Subject: Test Send Mail Hello World control d (this key combination of control key and d will finish the email.)

Can I send email from Linux command line?

sendmail Command Sendmail is one of the most popular SMTP servers in Linux. You can easily send emails directly from the command line using the sendmail command. To route the information, the sendmail command makes use of the network configured on your system.

Can we send email from shell script?

Another way to send email messages on a Linux system is by using the “sendmail” command. This is one of the most common email-sending commands used by Linux system operators. However, you will have to install the “sendmail” program to be able to run this command. Here, the email message is saved in a file named “mail.

How do I email a shell script output?

Run `mail' command by '-s' option with email subject and the recipient email address like the following command. It will ask for Cc: address. If you don't want to use Cc: field then keep it blank and press enter. Type the message body and press Ctrl+D to send the email.


1 Answers

The following works:

( echo "From: ${from}"; echo "To: ${to}"; echo "Subject: ${subject}"; echo "Content-Type: text/html"; echo "MIME-Version: 1.0"; echo ""; echo "${message}"; ) | sendmail -t 

For troubleshooting msmtp, which is compatible with sendmail, see:

  • https://wiki.archlinux.org/index.php/Msmtp
  • https://superuser.com/a/868900/9067
like image 89
Steven L Avatar answered Sep 30 '22 11:09

Steven L