Linux系统如何使用sendmail发送html文件
思韵闪耀
2013-03-18
0
    #!/bin/bash
    #send a html-email using sendmail command
    #author:mlsx mlsx(dot)xplore(at)gmail(dot)com
    #license:GPL
    from=”my@mydomain.com”
    subject=”test html-email using mail command”
    msgdate=`date +”%a, %e %Y %T %z”` # Leave alone
    emailtarget=”your@yourdomain.com”
    daemail=$(cat < Date: $msgdate
    From: $from
    To:$emailtarget
    Subject: $subject
    Mime-Version: 1.0
    Content-Type: text/html; charset=gb2312
    !)
    echo "$daemail" > msg.tmp
    echo >>msg.tmp
    cat test.html >>msg.tmp
    echo >> msg.tmp
    cat msg.tmp |sendmail -t
    rm -f msg.tmp    

这里是有这个问题的就是  “msgdate=`date +”%a, %e %Y %T %z”`”  来设置了发件时间,可实际上这样发出的邮件发件时间是不正确的,应该将这句和设置发件时间的语句去掉,正确的代码是下面的样子

    #!/bin/bash
    #send a html-email using sendmail command
    #author:mlsx mlsx(dot)xplore(at)gmail(dot)com
    #license:GPL
    from=”my@mydomain.com”
    subject=”test html-email using mail command”
    emailtarget=”your@yourdomain.com”
    daemail=$(cat <
    From: $from
    To:$emailtarget
    Subject: $subject
    Mime-Version: 1.0
    Content-Type: text/html; charset=gb2312
    !)
    echo "$daemail" > msg.tmp
    echo >>msg.tmp
    cat test.html >>msg.tmp
    echo >> msg.tmp
    cat msg.tmp |sendmail -t
    rm -f msg.tmp


【版权声明】
本站部分内容来源于互联网,本站不拥有所有权,不承担相关法律责任。如果发现本站有侵权的内容,欢迎发送邮件至masing@13sy.com 举报,并提供相关证据,一经查实,本站将立刻删除涉嫌侵权内容。

相关内容

热门资讯

Discus X论坛配置sen... Discuz x2.5 后台邮件设置方法其实和X2/x1.5基本一样,但很多同学都不注意一些细节,比...
redhat Linux系统配... 1 .检查Send Mail 的安装包 [root@sql root]# rpm -qa | gre...
使用Sendmail的反垃圾邮... 在最近几年,无处不在的垃圾邮件已使得所有邮件箱不堪重负,不断地需要工具以抗击这一无穷尽的垃圾邮件流。...