Reputation: 117
I am using phpmailer to send email. It gives me an error. Here is the code
$mail = new PHPMailer();
$mail->IsSMTP();
$mail->SMTPDebug = 2;
$mail->SMTPAuth = true;
$mail->SMTPSecure = "ssl";
$mail->Host = "smtp.gmail.com";
$mail->Port = 465;
$mail->AddAddress($email);
$mail->Username="[email protected]";
$mail->Password="mypassword";
$mail->SetFrom('[email protected]','name');
$mail->AddReplyTo("[email protected]"," name");
$mail->Subject = $subject;
$mail->MsgHTML($message);
$mail->Send();
Upvotes: 0
Views: 4040
Reputation: 461
try with this code
$mail = new PHPMailer(true);
$mail->IsSMTP();
$mail->SMTPDebug = 2;
$mail->SMTPAuth = true;
$mail->Host = "ssl://smtp.gmail.com";
$mail->Port = 465;
$mail->AddAddress($email);
$mail->Username="[email protected]";
$mail->Password="mypassword";
$mail->SetFrom('[email protected]','name');
$mail->AddReplyTo("[email protected]"," name");
$mail->Subject = $subject;
$mail->MsgHTML($message);
$mail->Send();
Upvotes: 1