tags:

views:

274

answers:

2

I have following system setup

  • Windows XP Service pack 2
  • WAMP 2.0
  • PHP 5.3

I've configured my php.ini file with the following:

smtp=smtp.gmail.com
smtp_port=25;

and my PHP code is

<?php
    mail('[email protected]','test subject','test body');
?>

The error I'm getting is

Warning: mail() [function.mail]: SMTP server response: 
530 5.7.0 Must issue a STARTTLS command first. 
4sm389277yxd.16 in C:\wamp\www\limosbusesjets\test.php on line 5

Any suggestions?

+3  A: 

Mail via Google needs to be run through SSL.

There are a lot of arcticles on subject, you might find this useful: http://deepakssn.blogspot.com/2006/06/gmail-php-send-email-using-php-with.html

Tatu Ulmanen
+1  A: 

I have always used PHPMailer for all my mailing needs. It has built in support for GMail as a server (and it's free)

I think your issue is that you are trying to use PHP's mail settings and not PHPMailer's Make sure you have the following set:

$mail               = new PHPMailer(); //Setup the mailer
$mail->IsSMTP();
//$mail->SMTPDebug      = 2;
$mail->SMTPAuth     = true;                  //enable SMTP authentication
$mail->SMTPSecure   = "ssl";                 //sets the prefix to the servier
$mail->Host         = "smtp.gmail.com";      //sets GMAIL as the SMTP server
$mail->Port         = 465;                   //set the SMTP port
$mail->Username     = $guser;    //GMAIL username
$mail->Password     = $gpwd;          //GMAIL password
$mail->AddReplyTo($fromAddress,$fromName);
$mail->From         = $guser;
$mail->FromName     = "Your name"; 
$mail->Subject      = $subject;  //E-Mail subject
$mail->AltBody      = $bodyAlt;   //Text Body
$mail->WordWrap     = 50;              //set word wrap
$mail->Priority = $priority;          //Mail priority
$mail->MsgHTML($ebody);
Jason
i was used that but it shows following errorSMTP Error: Could not authenticate
Mayan Alagar Pandi
Check out my edit...and SMTP on gmail is not port 25, it's 465. Take a look at docs/use_gmail.txt in the PHPMailer directory
Jason