Note that there are some explanatory texts on larger screens.

plurals
  1. POUnable to Send Email Using PHP
    primarykey
    data
    text
    <p>Preview: I have been trying to send an email using Moodle for a long time and finally decided to test sending an email by using a standard PHP mail() function to test if mail is working fine.</p> <p>BUT EVEN PHP DOES NOT SEND AN EMAIL!!</p> <p>Problem Scenario:</p> <p>This is my code for PHP:</p> <pre><code>$to = "receiver@gmail.com"; $subject = "Test mail"; $message = "Hello! This is a 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."; </code></pre> <p>The Error which I get is :</p> <pre><code> Warning: mail() [function.mail]: SMTP server response: 530 5.7.0 Must issue a STARTTLS command first. sz6sm10013088pab.5 - gsmtp in C:\Program Files (x86)\Moodle\server\moodle\user\edit.php on line 252 </code></pre> <p>I have tested my gmail server using Telnet and it is listening fine on Port 25. I have done everything that has been told by this error and other related posts</p> <p>Tried: "ssl://smtp.gmail.com" but it would simply give the following error:</p> <pre><code> Warning: mail() [function.mail]: Failed to connect to mailserver at "ssl://smtp.gmail.com" port 25, verify your "SMTP" and "smtp_port" setting in php.ini or use ini_set() in C:\Program Files (x86)\Moodle\server\moodle\user\edit.php on line 252 </code></pre> <p>even though openssl.dll has been uncommented in PHP.ini.</p> <pre><code> ;extension=php_tidy.dll extension=php_xmlrpc.dll ;extension=php_openssl.dll; </code></pre> <p>Also, I have configured the php.ini file(php.ini-production and php.ini-development also):</p> <pre><code>[mail function] ; For Win32 only. ; http://php.net/smtp SMTP = smtp.gmail.com ; http://php.net/smtp-port smtp_port = 25 ; For Win32 only. ; http://php.net/sendmail-from ;sendmail_from = username@gmail.com </code></pre> <p>But adding this to php.ini did not make much of a difference(therefore I resorted to set_ini()) as the server would coninue saying that "localhost smtp server cannot be configured on Port 25" though I had set the SMTP=smtp.gmail.com in php.ini.</p> <p>Any help on this would be greatly appreciated. Thanks in advance.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload