我在PHP中使用phpMailer
发送电子邮件时收到以下错误。
错误:
angularjs.js:93 POST http://localhost/crm/php/sendEmail.php 500 (Internal Server Error)
我在下面提供我的代码。
sendEmail.php:
require_once('class.phpmailer.php');
$postdata = file_get_contents("php://input");
$request = json_decode($postdata);
$to=$request->to;
$url=$request->url;
$subject=$request->subject;
$msg=$request->message;
$image=$request->image;
$mail = new PHPMailer(); // create a new object
$mail->IsSMTP(); // enable SMTP
$mail->SMTPAuth = true; // authentication enabled
$mail->SMTPSecure = 'ssl'; // secure transfer enabled REQUIRED for GMail
$mail->Host = "smtp.gmail.com";
$mail->Port = 587; // or 587
$mail->IsHTML(true);
$mail->Username = "********@gmail.com"; //Email that you setup
$mail->Password = "***********"; // Password
$mail->Subject=$subject;
$mail->Body=$message;
$mail->AddAddress("subhrajyotipradhan@gmail.com"); //Recipient name is optional
if(!$mail->send())
{
$result["value"]=0;
$result["msg"]=$mail->ErrorInfo;
}
else
{
$result["value"]=1;
$result["msg"]="Sent successfully";
}
echo json_encode($result);