我有电子邮件共享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';
}
}
?>
答案 0 :(得分:1)
您是否忘记了$ mail-> setFrom()上的'或仅仅是错字?
尝试
$mail->setFrom('funz4m05@gmail.com', 'mailer');