我在网上下载了一个5.0.2的phpMailer类,是个文件夹,里面主要三个文件也都有。我想用一个text的输入框,写些邮件内容发给十个左右的平时常用人员,假设内容为“祝各位新年好!”,用gmail的smtp
,当然,用其它也可以,最好用gmail,网上查了一些代码,测了都不好用,到现在没有一个人有收到内容,有的有提示出错,有的就没有提示了。请问如何写代码?可以贴上来,也可以发邮件到[email protected],只要能发送得出去,就给分。
,当然,用其它也可以,最好用gmail,网上查了一些代码,测了都不好用,到现在没有一个人有收到内容,有的有提示出错,有的就没有提示了。请问如何写代码?可以贴上来,也可以发邮件到[email protected],只要能发送得出去,就给分。
require_once './PHPMailer/class.smtp.php';$mail = new phpmailer();
$mail->IsSMTP();
$mail->SMTPAuth=true;
$mail->Host="smtp.163.com";
$mail->Port=25;$mail->Username="[email protected]";
$mail->Password="aaa";$mail->From="[email protected]";
$mail->FromName="aaa";
$mail->Subject="hello";
$mail->WordWrap=50;$mail->MsgHTML("HELLO WORLD!");
$mail->AddAddress("[email protected]",'xums');
$mail->IsHTML(true);if( !$mail->Send() ){
echo $mail->ErrorInfo;
}else{
echo "success";
}
include('Phpmailer.php');$mail = new Common_Phpmailer();
$mail->IsSMTP();
$mail->SMTPAuth = true;
$mail->SMTPSecure = "ssl";
$mail->Host = "smtp.gmail.com";
$mail->Port = 465;
$mail->CharSet = "gb2312";
$mail->Username = "[email protected]";
$mail->Password = "sdfdsf";
$mail->From = "[email protected]";
$mail->FromName = "haohaha";
$mail->Subject = "Linux Mailer Test!";
$mail->AltBody = "This is the body when user views in plain text format";
$mail->WordWrap = 50;
$content = 'phpmailer test';
$mail->MsgHTML($content);
$mail->AddReplyTo("[email protected]","Webmaster");
$mail->AddAddress('[email protected]',"First Last");
$mail->IsHTML(true);if(!$mail->Send()) {
// echo $mail->ErrorInfo;
}else{
echo 'Send OK!';
}
//注意:xxx是发送者,yyy是接受
将class.smtp.php文件中的这句话$this->smtp_conn = @fsockopen($host, // the host of the server
$port, // the port to use
$errno, // error number if any
$errstr, // error message if any
$tval); // give up after ? secs修改为$this->smtp_conn = @fsockopen('ssl://'.$host, // the host of the server
$port, // the port to use
$errno, // error number if any
$errstr, // error message if any
$tval); // give up after ? secs
再开启你的ssl扩展,由于我的是win下面,开扩展很简单哦呵呵~
extension=php_openssl.dll php代码如下:
require_once './PHPMailer/class.phpmailer.php';
require_once './PHPMailer/class.smtp.php';$mail = new phpmailer();
$mail->IsSMTP();
$mail->SMTPAuth=true;
$mail->Host="smtp.gmail.com";
$mail->Port=465;$mail->Username="[email protected]";
$mail->Password="aaaa";/*$mail->Username="[email protected]";
$mail->Password="aaaa";*/$mail->From="[email protected]";
$mail->FromName="xums";
$mail->Subject="hello";
$mail->WordWrap=50;$mail->MsgHTML("HELLO WORLD!");
$mail->AddAddress("[email protected]",'xums');
$mail->IsHTML(true);if( !$mail->Send() ){
echo $mail->ErrorInfo;
}else{
echo "success";
}
呵呵~~~
终于搞定了
require_once("../PHPMailer_v5.0.2/class.smtp.php");
//require_once '../PHPMailer_v5.0.2/class.phpmailer.php';
//require_once '../PHPMailer_v5.0.2/class.smtp.php';$mail = new phpmailer();
$mail->IsSMTP();
$mail->SMTPAuth=true;
$mail->Host="smtp.163.com";
$mail->Port=25;$mail->Username="[email protected]";
$mail->Password="我的密码";$mail->From="[email protected]";
$mail->FromName="lxdcoms";
$mail->Subject="hello";
$mail->WordWrap=50;$mail->MsgHTML("HELLO WORLD!");
$mail->AddAddress("[email protected]",'lxdcoms');
$mail->IsHTML(true);if (!$mail->Send())
echo $mail->ErrorInfo;
else
echo "success";在ie 6 和 firefox 3.6中测试,结果为:ie6:SMTP Error: SMTP Error: Could not connect to SMTP host. SMTP Error: Could not connect to SMTP host. firefox:SMTP Error: Could not connect to SMTP host. SMTP Error: Could not connect to SMTP host. 请问这段代码错误在哪里,还需要在哪里进行修改?因为在163中没通过,所以我还没有做gmail的进一步测试,请再进一步指点一下,谢谢!
请先确认php.ini中的扩展openssl是开启的
echo "ddd";
echo $errstr;
//echo $mail->ErrorInfo;
}else{
echo "ddd";
echo $errstr;
//echo 'Send OK!';
}就是这样,那个最简单的ddd字符串也输出不出来,更不用说是$errstr了,然而在前一句,就可以正确输出,这又是在哪里可能存在的问题呢?现在还需怎样改或测试?请指教,谢。
$this->smtp_conn = fsockopen($host, // the host of the server
$port, // the port to use
$errno, // error number if any
$errstr, // error message if any
$tval); // give up after ? secs
var_dump($this->smtp_conn);//这块
echo '<br<', $host, '<br>', $port, '<br>', $errno, '<br>', 'errstr:'.$errstr, '<br>', $tval, '<br>';//这块输出的东西弄出来看看
465
0
errstr:
10
在firefox 3.6中:aaabbbcccsmtp.gmail.com
465
0
errstr£º
10以上数据是否有价值,我接下来还需改哪才可以好呢?
465
0
errstr:
10firefox 3.6:aaabbbcccresource(4) of type (stream) smtp.gmail.com
465
0
errstr£º
10请帮忙再分析一下,谢谢。