从Linux服务器以html格式发送电子邮件-内容类型和html标签在电子邮件中也可见 [英] Send email from Linux server as html - Content type and html tags also visible in email

查看:66
本文介绍了从Linux服务器以html格式发送电子邮件-内容类型和html标签在电子邮件中也可见的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将电子邮件发送为html.

I am trying to send an email as html.

#!/bin/sh

#MAIL_LIST="gangadhar.n@xx.com"
MAIL_SENDER=foo

fnSendEmail(){
    echo ${BODY}| mail -r $MAIL_SENDER -s "$(echo "$MAIL_SUBJECT\nContent-Type: text/html")" "$MAIL_LIST"
}

MAIL_SUBJECT="Test email"

BODY="<html><body><div><h2>Hi All</h2><hr></div></body></html>";

fnSendEmail $BODY $MAIL_SENDER $MAIL_SUBJECT $MAIL_LIST 

我正在接收电子邮件,但如下所示,在邮件中也可以看到html标签和内容类型.

I am receiving email but html tags and Content type also visible in mails as below.

主题为

"Test email\nContent-Type: text/html"

电子邮件正文为:

<html><body><div><h2>Hi All</h2><hr></div></body></html> NOTICE TO RECIPIENT:  If you are not the intended recipient of this e-mail, you are prohibited from sharing, copying, or otherwise using or disclosing its contents.  If you have received this e-mail in error, please notify the sender immediately by reply e-mail and permanently delete this e-mail and any attachments without reading, forwarding or saving them.  Thank you.

提前谢谢

推荐答案

我已经使用sendmail完成了

I have done it using sendmail

#MAIL_LIST1="Gangadhar.N@xx.com"
MAIL_SENDER=dap

fnSendEmail(){
(
  echo To: $MAIL_LIST
  echo Cc: $MAIL_LIST
  echo From: dap53
  echo "Content-Type: text/html; "
  echo Subject: $MAIL_SUBJECT
  echo
  echo $BODY
) | /usr/sbin/sendmail -t
}

MAIL_SUBJECT="Test email"
BODY="<html><body>Sample</body></html>"

fnSendEmail $BODY $MAIL_SENDER $MAIL_SUBJECT $MAIL_LIST

这篇关于从Linux服务器以html格式发送电子邮件-内容类型和html标签在电子邮件中也可见的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆