我得到錯誤SMTP連接的PHPMailer()失敗與本地主機的PHPMailer:得到錯誤SMTP連接()失敗與本地主機
2015-09-10 09:34:48 Connection: opening to ssl://smtp.gmail.com:587, timeout=300, options=array () 2015-09-10 09:34:48 SMTP ERROR: Failed to connect to server: (0) 2015-09-10 09:34:48 SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting Message could not be sent.Mailer Error: SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting
- 是它的PHPMailer不能在本地主機上運行?
- 如果我真的想在本地主機上運行,我該如何更改代碼?
- 我嘗試使用mailto函數是爲我工作,但我想改變整個事情。
可以給出任何建議。我真的很想學習它。
這是github上的代碼: require'PHPMailer/PHPMailerAutoload.php';
$mail = new PHPMailer; //$mail->SMTPDebug = 4; // Enable verbose debug output $mail->isSMTP(); // Set mailer to use SMTP $mail->Host = 'smtp.gmail.com'; // Specify main and backup SMTP servers $mail->SMTPAuth = true; // Enable SMTP authentication $mail->Username = '[email protected]'; // SMTP username $mail->Password = 'mygmailpassword'; // SMTP password $mail->SMTPSecure = 'ssl'; // Enable TLS encryption, `ssl` also accepted $mail->Port = 465; // TCP port to connect to //$mail->Host = 'tls://smtp.gmail.com:587'; $mail->From = '[email protected]'; $mail->FromName = 'Mailer'; $mail->addAddress('[email protected]', 'Joe User'); // Add a recipient $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; } else { echo 'Message has been sent'; }
你可以分享可能需要更改的代碼嗎?據我所知,迄今爲止,您只發布了錯誤消息。 – lenz
這是我從github複製的代碼。我確實改變了sendmail.ini和php.ini文件,但仍然無法正常工作。 – ikramlim