【发布时间】:2018-10-04 15:31:11
【问题描述】:
我有电子邮件共享 PHP 代码。它对localserver(localhost) 非常有效。我已将此代码托管到在线服务器,但它无法正常工作且没有响应。如何解决这个问题?在这里检查我的代码..
if(isset($_POST['shareemail'])){
require "php-mailer-master/PHPMailerAutoload.php" ;
$mail = new PHPMailer;
//$mail->SMTPDebug = 3; // Enable verbose debug output
$mail->isSMTP(); // Set mailer to use SMTP
$mail->Host = 'smtp.gmail.com';// smtp2.example.com'; // Specify main and backup SMTP servers
$mail->SMTPAuth = true; // Enable SMTP authentication
$mail->Username = 'funz4m05@gmail.com' ; // SMTP username
$mail->Password = '******' ; // SMTP password
$mail->SMTPSecure = 'tls'; // Enable TLS encryption, `ssl` also accepted
$mail->Port = 587; // TCP port to connect to
$mail->setFrom(funz4m05@gmail.com, 'mailer');
$mail->addAddress('to@gmail.com'); // Name is optional
$mail->isHTML(true); // Set email format to HTML
$mail->Subject = 'this subject' ;
$mail->Body = "<b>html</b>" ; // this is html format
if(!$mail->send()) {
echo 'Message could not be sent.';
echo 'Mailer Error: ' . $mail->ErrorInfo;
} else {
echo 'Message has been sent';
}
}
?>
【问题讨论】:
-
“但不工作和任何响应”是什么意思?实际发生了什么?
-
如果您想使用 gmail 发送电子邮件,请参考:github.com/PHPMailer/PHPMailer/blob/master/examples/gmail.phps
-
@John Conde 我没有收到任何错误......并且没有发送邮件......提交按钮后也是如此......没有任何更改。