- 论坛徽章:
- 0
|
小公猫,不知道了吧? 我搞清楚了,请看下面的正确程序:
#!/usr/bin/perl -w
#perl -MCPAN -e shell
#cpan>install Net::SMTP_auth
use Net::SMTP;
use Net::SMTP_auth;
use MIME::Base64;
$mail_server = 'smtp.163.com';
$mail_from = 'me@163.com';
$mail_to = 'me@163.com';
$uname='me';
$passwd='mypasswd';
#开启Debug模式
$smtp = Net::SMTP->new("$mail_server" , Debug => 1);
#普通发送模式
#$smtp = Net::SMTP->new("$mail_server" );
$smtp->auth("$uname", "$passwd");
$smtp->mail("$mail_from");
$smtp->to("$mail_to");
$smtp->data();
$smtp->datasend("To: $mail_from\n");
$smtp->datasend("Cc: 'me@163.com', 'me2@gmail.com'\n"); # 可抄送给多个人
$smtp->datasend("From: $mail_from\n");
$smtp->datasend("Reply-To: $mail_from\n");
$smtp->datasend("Return-Path: $mail_from\n");
$smtp->datasend("Subject: 1 Subject\n");
#$smtp->datasend("Content-Type: text/plain; ChartSet=gb2312");
$smtp->datasend("\n"); # 解决了正文没有显示的问题
# Send your email content
$smtp->datasend("I am a cat!\n");
$smtp->datasend("\n");
$smtp->dataend();
$smtp->quit; |
|