Reputation: 91
require("phpmailer.inc.php");
class sendmail
{
public static function sendAccountActivateMail($to,$subject,&message)
{
$flg = false;
try
{
$mail= new PHPMailer();
$mail->IsSMTP();
$mail->SMTPAuth= true;
$mail->SMTPSecure= "tls";
$mail->Host= "smtp.gmail.com";
$mail->Port= 587;
$mail->Username= "[email protected]";
$mail->Password= "xxxxxx";
$mail->AddReplyTo("[email protected]");
$mail->From= "[email protected]";
$mail->FromName= "Website";
$mail->Subject= $subject;
$mail->WordWrap= 50;
$mail->Body = $message;
$mail->AddAddress($to);
$mail->Send();
}
catch(Exception $e)
{
$flg = false;
}
return $flg;
}
}
Trying to send mail through phpmailer with smtp. turning on debug gives me error:
SMTP -> ERROR: RCPT not accepted from server: 550 SMTP AUTH is required for message submission on port 587 SMTP -> ERROR: DATA command not accepted from server: SMTP -> NOTICE: EOF caught while checking if connected
Upvotes: 8
Views: 12630
Reputation: 51
It looks like port 587 is blocked. Try using
$mail= new PHPMailer();
$mail->IsSMTP();
$mail->SMTPAuth= true;
$mail->SMTPSecure= "ssl";
$mail->Host= "smtp.gmail.com";
$mail->Port= 465;.....
Upvotes: 5