linux mail adding content type headers not working
Try
echo "<b>HTML Message goes here</b>" | mail -s "$(echo -e "This is the subject\nContent-Type: text/html")" foo@example.com
How to send HTML email using linux command line
Force Content Type with sendmail
I have a non solution, instead of to force my mail to be in text/plain
, I will send a mail in text/html
but I will add the <pre>
tag to open and close my output file... And because it's now in text/html
, the <pre>
tag is not displayed as <pre>
It's not what I excepted but it works. So my previous script simply become:
#!/bin/bash
SENDMAIL_BIN='/usr/sbin/sendmail'
FROM_MAIL_ADDRESS='noreply@plop.com'
FROM_MAIL_DISLAY='Test format mail'
RECIPIENT_ADDRESSES='me@plop.com'
MAIL_CMD="$SENDMAIL_BIN -f $FROM_MAIL_ADDRESS -F \"$FROM_MAIL_DISLAY\" $RECIPIENT_ADDRESSES"
(echo "Subject: Test format";echo -e "MIME-Version: 1.0\nContent-Type: text/html;\n" && echo '<pre>' && cat output.txt && echo '</pre>') | eval $MAIL_CMD
Why Headers Preventing mail from sending?
The sender information should be inside the headers
Hence, please change the following lines:
$headers =
"MIME-Version: 1.0\r\n" .
"Content-Type: text/html; charset=UTF-8";
if(mail($receiver, $subject, $email_template, $sender, $headers))
to
$sender = "iusername@host.com";
$headers = "From: $sender <$sender>\r\nReply-To: $sender\r\n";
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-Type: text/html; charset=utf-8\r\n";
if(mail($receiver, $subject, $email_template, $headers))
Related Topics
What Is The Side Effect of Setting Tcp_Max_Tw_Buckets to a Very Small Value
Path Environment Variable in Linux
How to Modify The Linux Kernel to Change The Version String That Uname Returns
Code Behind Rstudio Server Export Function
Gatttool: Limited to 5 Connections
Install Gulp Browserify Gives Error Always
Assign Output of a Shell Command to a Variable
Getting Kernel Version from The Compressed Kernel Image
Sharing Executable Memory Pages in Linux
How to Check If a UId Exists in an Acl in Linux
Grep Array Parameter of Excluded Files
Getting Root Privileges in Ansible
How to Convert a Text/Plain to Text/X.Shellscript
How to Do Simple Arithmetic in Sed Addresses
Quickest Way to Select/Copy Lines Containing String from Huge Txt.Gz File
Gstreamer Video Output Position Tracking and Seeking