作者:ll66068ll你 | 来源:互联网 | 2014-06-12 18:37
把下载的PHPMailer放到ThinkPHP\Extend\Vendor下,把下面的代码拷到ThinkPHP\Common中的common.php中:functionSendMail($address,$title,$me...
把下载的PHPMailer放到ThinkPHP\Extend\Vendor下,把下面的代码拷到ThinkPHP\Common中的common.php中:
- function SendMail($address,$title,$message)
- {
- $mail=new PHPMailer();
-
- $mail->IsSMTP();
-
-
- $mail->CharSet='UTF-8';
-
-
- $mail->AddAddress($address);
-
-
- $mail->Body=$message;
-
-
- $mail->From=C('MAIL_ADDRESS');
-
-
- $mail->FromName=C('MAIL_FromName');
-
-
- $mail->Subject=$title;
-
-
- $mail->Host=C('MAIL_SMTP');
-
-
- $mail->SMTPAuth=true;
-
-
- $mail->Username=C('MAIL_LOGINNAME');
- $mail->Password=C('MAIL_PASSWORD');
- if($mail->Send())
- {
- return true;
- }
- else
- {
- return false;
- }
- }
使用的时候只需调用SendMail函数即可.