ssl - Unable to Send Email Using PHP -


preview: have been trying send email using moodle long time , decided test sending email using standard php mail() function test if mail working fine.

but php not send email!!

problem scenario:

this code php:

$to = "receiver@gmail.com"; $subject = "test mail"; $message = "hello! simple email message."; $from = "username150@gmail.com"; $headers = "from:" . $from; ini_set( "sendmail_from", "username@gmail.com" );  ini_set( "smtp", "smtp.gmail.com" );   ini_set( "smtp_port", "25" ); ini_set("username","username0@gmail.com");  ini_set("password","password"); mail($to,$subject,$message,$headers); echo "mail sent."; 

the error :

    warning: mail() [function.mail]: smtp server response: 530 5.7.0 must issue starttls                command first. sz6sm10013088pab.5 - gsmtp in c:\program files (x86)\moodle\server\moodle\user\edit.php on line 252 

i have tested gmail server using telnet , listening fine on port 25. have done has been told error , other related posts

tried: "ssl://smtp.gmail.com" give following error:

    warning: mail() [function.mail]: failed connect mailserver @  "ssl://smtp.gmail.com" port 25, verify "smtp" , "smtp_port" setting in php.ini or use ini_set() in c:\program files (x86)\moodle\server\moodle\user\edit.php on line 252 

even though openssl.dll has been uncommented in php.ini.

 ;extension=php_tidy.dll  extension=php_xmlrpc.dll  ;extension=php_openssl.dll; 

also, have configured php.ini file(php.ini-production , php.ini-development also):

[mail function] ; win32 only. ; http://php.net/smtp smtp = smtp.gmail.com ; http://php.net/smtp-port smtp_port = 25  ; win32 only. ; http://php.net/sendmail-from ;sendmail_from = username@gmail.com 

but adding php.ini did not make of difference(therefore resorted set_ini()) server coninue saying "localhost smtp server cannot configured on port 25" though had set smtp=smtp.gmail.com in php.ini.

any on appreciated. in advance.

you've configured port 25 mail server.

the error message you're getting says it's unable connect localhost:25.

therefore have 2 options:

  1. install / configure smtp server on localhost port 25
  2. change configuration different port can connect to:

.

  • port tls/starttls: 587
  • port ssl: 465

this support forum thread may helpful.


Comments

Popular posts from this blog

How to mention the localhost in android -

php - Calling a template part from a post -

c# - String.format() DateTime With Arabic culture -