I am trying to send email from php to a gmail account. I have the following settings on my laptop:
- Windows 8
- Internet connection
- XAMPP 1.7.4, PHP Version 5.3.5,
I have the following php.ini settings
[mail function]
; For Win32 only. ; http://php.net/smtp SMTP = smtp.gmail.com ;
http://php.net/smtp-portsmtp_port = :465
; For Win32 only. ; http://php.net/sendmail-from ;sendmail_from =
postmaster@localhost; For Unix only. You may supply arguments as well (default: "sendmail
-t -i"). ; http://php.net/sendmail-path ;sendmail_path = "\"C:\xampp\sendmail\sendmail.exe\" -t"
The following is the php code:
<?php
$to = 'goodmandiamont@gmail.com';
$subject = 'hi';
$msg = 'Test';
$headers = 'From: postmaster@localhost' ."\r\n" .
'Reply-To: shawn.danisa@gmail.com' . "\r\n" .
'X-Mailer: PHP /' . phpversion();
mail($to, $subject,$msg,$headers);
?>
I get the following error:
Warning: mail() [function.mail]: SMTP server response: 530 5.7.0 Must issue a STARTTLS command first.
I also made sure the IMAP setting is enabled on the gmail settings. I also checked to see If I will find the following lines on the php.ini file:
ini_set("SMTP","ssl://smtp.gmail.com");
ini_set("smtp_port","465");
But no luck, I just cant find them anywhere. Please assist, I am new to php.
Best Answer
Initially, you make sure your PHP installation has SSL support (look for an "openssl" section in the output from
phpinfo()
).Again you need to set the following settings in your PHP configuration PHP.ini
Hope this solves your problem.