专注收集记录技术开发学习笔记、技术难点、解决方案
网站信息搜索 >> 请输入关键词:
您当前的位置: 首页 > CGI

CGI怎么发送邮件呀

发布时间:2010-05-20 14:01:29 文章来源:www.iduyao.cn 采编人员:星星草
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;等这些模块。
Perl code

#!/usr/bin/perl -w
use 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;
    $boundary
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: quoted-printable




$boundary
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: quoted-printable

$body
$boundary--

END_OF_BODY

sendmail(%mail) || print "Error: $Mail::Sendmail::errorn";
}
友情提示:
信息收集于互联网,如果您发现错误或造成侵权,请及时通知本站更正或删除,具体联系方式见页面底部联系我们,谢谢。

其他相似内容:

热门推荐: