所以我把所有的文件,並更改SMTP信息,但由於某種原因,我無法讓它的工作。這裏是PHP的樣子..PHPMailer不會工作?
<?php
require 'phpmailer/class.phpmailer.php';
$mail = new PHPMailer;
$mail->isSMTP(); // Set mailer to use SMTP
$mail->Host = 'smtp.mail.yahoo.com'; // Specify main and backup server
$mail->SMTPAuth = true; // Enable SMTP authentication
$mail->Username = 'MYEMAILADDRESS'; // SMTP username
$mail->Password = 'MYEMAILPASSWORD'; // SMTP password
$mail->SMTPSecure = 'tls'; // Enable encryption, 'ssl' also accepted
$mail->From = '[email protected]';
$mail->FromName = 'Mailer';
$mail->addAddress('[email protected]', 'Josh Adams'); // Add a recipient
$mail->addAddress('[email protected]'); // Name is optional
$mail->addReplyTo('[email protected]', 'Information');
$mail->addCC('[email protected]');
$mail->addBCC('[email protected]');
$mail->WordWrap = 50; // Set word wrap to 50 characters
$mail->isHTML(true); // Set email format to HTML
$mail->Subject = 'Here is the subject';
$mail->Body = 'This is the HTML message body <b>in bold!</b>';
$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;
exit;
}
echo 'Message has been sent';
?>
我打開頁面時出現此錯誤。
SMTP錯誤:無法連接到SMTP主機。郵件無法發送。郵件錯誤:SMTP錯誤:無法連接到SMTP主機。
請幫忙!
試圖與雅虎本身連接?或任何其他服務器? –
我不明白你在問什麼。 –
你可以ping smtp.mail.yahoo.com嗎? – pregmatch