新聞中心
這里有您想知道的互聯(lián)網(wǎng)營銷解決方案
怎么在php5.5中使用PHPMailer-5.2發(fā)送郵件-創(chuàng)新互聯(lián)
這篇文章給大家介紹怎么在php5.5中使用PHPMailer-5.2發(fā)送郵件,內(nèi)容非常詳細,感興趣的小伙伴們可以參考借鑒,希望對大家能有所幫助。
SMTPDebug = 3; // Enable verbose debug output $mail->isSMTP(); // Set mailer to use SMTP $mail->Host = 'smtp.exmail.qq.com'; // Specify main and backup SMTP servers $mail->SMTPAuth = true; // Enable SMTP authentication $mail->Username = '[email protected]'; // SMTP username $mail->Password = 'yourpassword'; // SMTP password $mail->SMTPSecure = 'ssl'; // Enable TLS encryption, `ssl` also accepted $mail->Port = 465; // TCP port to connect to $mail->setFrom('[email protected]', 'Mailer'); $mail->addAddress('[email protected]', 'Ryan Miao'); // Add a recipient $mail->addAddress('[email protected]'); // Name is optional // $mail->addReplyTo('[email protected]', 'Information'); $mail->addCC('[email protected]'); $mail->addBCC('[email protected]'); $mail->addAttachment('/var/tmp/file.tar.gz'); // Add attachments $mail->addAttachment('/tmp/image.jpg', 'new.jpg'); // Optional name $mail->isHTML(true); // Set email format to HTML $mail->Subject = 'Here is the subject'; $mail->Body = 'This is the HTML message body in bold!'; $mail->AltBody = 'This is the body in plain text for non-HTML mail clients'; if(!$mail->send()) { echo 'Message could not be sent.'; echo 'Mailer Error: ' . $mail->ErrorInfo; } else { echo 'Message has been sent'; }
開啟SMTPDebug可以查看日志
`0` No output
`1` Commands
`2` Data and commands
`3` As 2 plus connection status
`4` Low-level data output
錯誤信息保存在$mail->ErrorInfo
對象中。
保存為mail.php, 命令行執(zhí)行
php mail.php
關(guān)于怎么在php5.5中使用PHPMailer-5.2發(fā)送郵件就分享到這里了,希望以上內(nèi)容可以對大家有一定的幫助,可以學(xué)到更多知識。如果覺得文章不錯,可以把它分享出去讓更多的人看到。
網(wǎng)頁名稱:怎么在php5.5中使用PHPMailer-5.2發(fā)送郵件-創(chuàng)新互聯(lián)
標(biāo)題網(wǎng)址:http://fisionsoft.com.cn/article/dsdodi.html