欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  php教程

使用 PHPMAILER 发送邮件实例

程序员文章站 2024-01-07 16:30:34
...
'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 "恭喜发送成功!"; }



上一篇:

下一篇: