CGI如何发送邮件呀?
各位,请教一下,我装的是WINDOWS SERVER 2003,安装有CGI和Perl程序,请问如何发送网页中的内容到指定的邮箱呀?在网上找了好久都没有合适的内容,请各位指教一下,最好能给个例子,感激不尽.
Best Regards.
peng
[解决办法]
用libnet:
http://search.cpan.org/~gbarr/libnet-1.22/Net/SMTP.pm
或者上search.cpan.org找找,类似于这种:
http://search.cpan.org/~rjbs/Email-Send-2.198/lib/Email/Send/SMTP.pm
[解决办法]
按ls 说的,用 perl 强大的第三方代码库 CPAN 提供的libnet。
[color=#FF0000]我纯jf了lor]
[解决办法]
发电子邮件可以用MIME::Lite模块,比较方便。
[解决办法]
这里有PERL发邮件的例子,你可以用一下,不过要安装Mail::Sendmail 0.79;等这些模块。
#!/usr/bin/perl -wuse Mail::Sendmail 0.79;use HTML::Entities;use Encode;use MIME::QuotedPrint;use MIME::Base64;sub sendEmail{ my($from,$to,$subject,$body)=@_; $subject= encode_utf8(decode_entities($subject)); $body=encode_utf8(decode_entities($body)); $boundary = "====" . time() . "===="; %mail = ( from => "$from", to => "$to", subject => "$subject" ); $mail{'content-type'} = "multipart/related; boundary=\"$boundary\""; $boundary = '--'.$boundary; my $nowtime = time;$mail{body} = <<END_OF_BODY; $boundaryContent-Type: text/plain; charset="utf-8"Content-Transfer-Encoding: quoted-printable$boundaryContent-Type: text/plain; charset="utf-8"Content-Transfer-Encoding: quoted-printable$body$boundary--END_OF_BODYsendmail(%mail) || print "Error: $Mail::Sendmail::error\n";}