Note that there are some explanatory texts on larger screens.

plurals
  1. POhow to get a batch file send a email using PHP?
    text
    copied!<p>I have found numerous posts on Stacked overflow and other forums regarding sending the email using a batch file like: <a href="https://stackoverflow.com/questions/712392/send-email-using-gmail-smtp-server-from-php-page">Send email using the GMail SMTP server from a PHP page</a></p> <p>But none seems to work for me... I have been able to schedule task.. using Windows task scheduler and wrote the batch file:</p> <p>@echo start C:\wamp\bin\php\php5.3.1\php.exe -f C:\wamp\www\email.php</p> <p>PHP file shows a simple script as below:</p> <pre><code>&lt;?php require_once "Mail.php"; $from = "Prashant Yahoo &lt;prashant.balan@yahoo.co.in&gt;"; $to = "Prashant Hotmail &lt;prashant.balan@hotmail.com&gt;"; $subject = "Hi!"; $body = "Hi,\n\nHow are you?"; $host = "ssl:\\smtp.gmail.com"; $port = "465"; $username = "&lt;user@gmail.com&gt;"; or user.gmail.com as stated in the above SO link $password = "password"; $headers = array ('From' =&gt; $from, 'To' =&gt; $to, 'Subject' =&gt; $subject); $smtp = Mail::factory('smtp', array ('host' =&gt; $host, 'port' =&gt; $port, 'auth' =&gt; true, 'username' =&gt; $username, 'password' =&gt; $password)); $mail = $smtp-&gt;send($to, $headers, $body); if (PEAR::isError($mail)) { echo("&lt;p&gt;" . $mail-&gt;getMessage() . "&lt;/p&gt;"); } else { echo("&lt;p&gt;Message successfully sent!&lt;/p&gt;"); } ?&gt; </code></pre> <p>I have PEAR setup on my local host already and everything I need. I even downloaded the latest OpenSSL and replaced the necessary files and as directed here and set environment variables: <a href="http://raibledesigns.com/wiki/Wiki.jsp?page=ApacheSSL" rel="nofollow noreferrer">http://raibledesigns.com/wiki/Wiki.jsp?page=ApacheSSL</a></p> <p><strong>I receive the following error: <p>Failed to connect to ssl://smtp.gmail.com:465 [SMTP: Failed to connect socket: Unable to find the socket transport "ssl" - did you forget to enable it when you configured PHP? (code: -1, response: )]</p></strong></p> <p>How to solve this? Please help..</p> <p><strong><em>ANSWER</em></strong> <strong>OPEN YOUR PHP.INI FILE INSIDE THE C:\PHP or in my case C:\WAMP\BIN\PHP\PHP 5.3.8 and remove the semi-colon's ahead of: extension=php_openssl.dll and extension=php_sockets.dll Hope this would help someone else! ~~~~~~ Special Thanks to Tomas ~~~~~~~</strong></p>
 

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