从perl脚本以html格式发送邮件

从perl脚本以html格式发送邮件,第1张

概述我正在使用unix环境并有一个perl脚本来发送邮件,但我需要发送 HTML格式的邮件,但它打印,因为它是HTML代码.所以任何人都可以让我知道它如何 *** 纵或编译HTML和发送格式化的邮件. #!/usr/bin/perl#print "Content-type: text/html\n\n";print("enter my name");chop($name=<stdin>);&mail 我正在使用unix环境并有一个perl脚本来发送邮件,但我需要发送 HTML格式的邮件,但它打印,因为它是HTML代码.所以任何人都可以让我知道它如何 *** 纵或编译HTML和发送格式化的邮件.

#!/usr/bin/perl#print "Content-type: text/HTML\n\n";print("enter my name");chop($name=<stdin>);&mail();sub mail{$Title='perl';$to='[email protected]';$from= '[email protected]';$subject=$name;open(MAIL,"|/usr/sbin/sendmail -t");## Mail headerprint MAIL "To: $to\n";print MAIL "From: $from\n";print MAIL "Subject: $subject\n\n";## Mail Bodyprint MAIL $name;print MAIL "<HTML><body><p>";print MAIL "<b>Hello</b>";print MAIL "This is a test message from Cyberciti.biz! You can write your";print MAIL "</p></body></HTML>";##print MAIL "$Title";close(MAIL);}

它在邮件中打印:

<HTML><body><p><b>Hello</b>This is a test message from Cyberciti.biz! You can write your</p></body></HTML>

像这样…因为它似乎没有将其转换为HTML格式.
所以请帮助我.

解决方法 使用 Mime::Lite.这个例子:

my $msg = MIME::lite->new(     To      => '[email protected]',Subject => 'HTML example',Type    => 'text/HTML',Data    => '<h1>Hello World!</h1>');$msg->send();
总结

以上是内存溢出为你收集整理的从perl脚本以html格式发送邮件全部内容,希望文章能够帮你解决从perl脚本以html格式发送邮件所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/langs/1236300.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-06-06
下一篇 2022-06-06

发表评论

登录后才能评论

评论列表(0条)

保存