<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Mailer {
var $mail;
public function __construct()
{
require_once('PHPMailer_5.2.2/class.phpmailer.php');
// the true param means it will throw exceptions on errors, which we need to catch
$this->mail = new PHPMailer(true);
$this->mail->IsSMTP(); // telling the class to use SMTP
$this->mail->CharSet = "utf-8"; // 一定要設定 CharSet 才能正確處理中文
//$this->mail->SMTPDebug= 0; // enables SMTP debug information
$this->mail->SMTPAuth = true; // enable SMTP authentication
//$this->mail->SMTPSecure = "ssl"; // sets the prefix to the servier
$this->mail->Host = "smtp.163.com"; // sets 163 as the SMTP server
//$this->mail->Port = 465; // set the SMTP port for the 163 server
$this->mail->Username = "xxxxxx@163.com";// 163 username
$this->mail->Password = "xxxxxxxxx"; // 163 password
/// $this->mail->AddReplyTo('@163.com', 'YOUR_NAME'); //回复地址(可填可不填)
//$this->mail->SetFrom('YOUR_GAMIL@163.com', 'YOUR_NAME');
}
public function sendmail($to, $to_name, $subject, $body){
try{
$this->mail->From = 'xxxx@163.com';
$this->mail->FromName = 'xxxxxx';
$this->mail->AddAddress($to, $to_name);
$mail->WordWrap = 50; // Set word wrap to 50 characters
$this->mail->IsHTML(true); // 使用html格式
$this->mail->Subject = $subject;
$this->mail->Body = $body;
$this->mail->Send();
echo "Message Sent OK</p>\n";
} catch (phpmailerException $e) {
echo $e->errorMessage(); //Pretty error messages from PHPMailer
} catch (Exception $e) {
echo $e->getMessage(); //Boring error messages from anything else!
}
}
}
/* End of file mailer.php */ 谢谢,分享。我这遇见个问题,发送完邮件后,返回去网站所有的js都失效了,但是js路径没什么问题,在浏览器谦容模式下出现的问题。怎么回事呢? 蜗牛999 发表于 2013-7-31 11:54 static/image/common/back.gif
谢谢,分享。我这遇见个问题,发送完邮件后,返回去网站所有的js都失效了,但是js路径没什么问题,在浏览器 ...
是的。谢谢你。 return调用函数出问题了。
先下载下来看看 今天使用了一下phpmailer,发现QQ和163邮箱死活不能发邮件。
情况如下:
1、如果使用ssl,就提示ssl有问题,请配置PHP;
2、如果使用默认的tsl,就是提示smtp无法连接;
网上搜索了一下,发现有人说是scoket没开,虽有些莫名,但开启配置后发现还是没用;然后关了socket再开ssl,就成功了~~
根据之前网友和其它论坛网友的解释,我觉得原因如下:
1、为了防止垃圾邮件乱发,如果不使用ssl,则禁止其它服务器发送邮件(客户端可以);
2、如果使用ssl方式发邮件,则所在服务器必须启用ssl的dll,名称为:php_openssl.dll
页:
1
[2]