首页 >php教程 >php手册 >使用 PHPMAILER 发送邮件实例

使用 PHPMAILER 发送邮件实例

WBOY
WBOY原创
2016-06-21 08:50:52818浏览

 

<?php include (&#39;class/class.phpmailer.php&#39;);

$config = array(
        &#39;host&#39;=>'smtp.163.com',
        'port'=>'25',
        'user'=>'***',
        'passwd'=>'****',
        'from'=>'juva_zz@163.com',
        'fromname'=>'郑州',
        
        );
$subject = 'this is a test mail';
$body = '
测试内容
这是内容
'; $address='379018082@qq.com'; $username='本人'; $mail = new PHPMailer(); $mail->CharSet = 'gb2312'; $mail->IsSMTP(); $mail->Host = $config['host']; $mail->Port = $config['port']; $mail->From = $config['from']; $mail->FromName = $config['fromname']; $mail->SMTPAuth = true; $mail->Username = $config['user']; $mail->Password = $config['passwd']; $mail->Subject=$subject; $mail->AltBody="text/html"; $mail->MsgHTML($body); $mail->AddAddress($address,$username); if(!$mail->Send()) { echo "Mail Error :".$mail->ErrorInfo; }else { echo "恭喜发送成功!"; }



声明:
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn