PHP mail not sending to gmail

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
dineshsjce
Forum Newbie
Posts: 2
Joined: Wed Jun 29, 2011 8:27 am

PHP mail not sending to gmail

Post 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!";
}
?>
User avatar
Apollo
Forum Regular
Posts: 794
Joined: Wed Apr 30, 2008 2:34 am

Re: PHP mail not sending to gmail

Post 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";
?
dineshsjce
Forum Newbie
Posts: 2
Joined: Wed Jun 29, 2011 8:27 am

Re: PHP mail not sending to gmail

Post by dineshsjce »

Thanks for your reply. But no luck :-)
Post Reply