Page 1 of 1

PHP mail not sending to gmail

Posted: Wed Jun 29, 2011 8:38 am
by dineshsjce
Dear Friends,

I am trying to send the mail to the gmail using the below code. But nothing is happening. When I click the submit button in web pags, a blank page displays.
I am struggling very hard. Pls help. Also if you have any working code, pls share with me. Thanks a lot in advance.



<?php

require_once("class.phpmailer.php");
$mail = new PHPMailer();

$body = "hi welcome";
$mail->IsSMTP();
$mail->SMTPDebug = 2;
$mail->SMTPAuth = true;
$mail->SMTPSecure = "tls";
$mail->Host = "smtp.gmail.com";
$mail->Port = 465;
$mail->Username = "mymail@gmail.com";
$mail->Password = "mypwd";
$mail->SetFrom('mymail1@rediffmail.com');

$mail->AddReplyTo("mymail1@rediffmail.com");
$mail->Subject = "PHPMailer Testing";

$mail->AltBody = "To view the message, please use an HTML compatible email viewer!"; // optional, comment out and test

$mail->MsgHTML($body);

$address = "polymers24@gmail.com";
$mail->AddAddress($address, "Polymers");

.if(!$mail->Send()) {
.echo "Mailer Error: " . $mail->ErrorInfo;
} else {
echo "Message sent!";
}
?>

Re: PHP mail not sending to gmail

Posted: Wed Jun 29, 2011 10:06 am
by Apollo
Any improvement if you change this:
dineshsjce wrote:

Code: Select all

$mail->SMTPSecure = "tls";               
$mail->Host       = "smtp.gmail.com";    
$mail->Port       = 465;
into:

Code: Select all

$mail->Host = "ssl://smtp.gmail.com:465";
?

Re: PHP mail not sending to gmail

Posted: Wed Jun 29, 2011 10:18 am
by dineshsjce
Thanks for your reply. But no luck :-)