使用 Perl 发送 HTML 消息
如果您想使用 sendmail 发送 HTML 格式的电子邮件,只需在电子邮件的标头部分添加以下内容:Content-type: text/html\n ,如下所示 −
#!/usr/bin/perl $to = '[email protected]'; $from = '[email protected]'; $subject = 'Test Email'; $message = '<h1>This is test email sent by Perl Script</h1>'; open(MAIL, "|/usr/sbin/sendmail -t"); # Email Header print MAIL "To: $to\n"; print MAIL "From: $from\n"; print MAIL "Subject: $subject\n\n"; print MAIL "Content-type: text/html\n"; # Email Body print MAIL $message; close(MAIL); print "Email Sent Successfully\n";
广告