php - Sending mail from localhost when working on wifi connection -
what changes should in php.ini
send mail localhost.i using college wifi.
try , let me know error after tell changes need in php.ini
<?php error_reporting(0); require_once "mail.php"; $from="from email"; //enter email of sender $to="recepient email"; //enter email $subject="subject"; $body="content"; $host="ssl://smtp.gmail.com"; $port="465"; $username="your gmail account user name"; $pwd="your gmail account password"; $headers = array ('from' => $from, 'to' => $to, 'subject' => $subject); $headers["content-type"] = 'text/html; charset=utf-8'; $smtp = mail::factory('smtp', array ('host' => $host, 'port' => $port, 'auth' => true, 'username' => $username, 'password' => $pwd)); //send email using pear sned option $mail = $smtp->send($to, $headers, $body); //if errors occurs if (@pear::iserror($mail)) { echo("<p>" . $mail->getmessage() . "</p>"); } else { echo("<p>message sent!</p>"); } ?>
if using xampp pear installed , need change php.ini.
**first of need uncomment extension=php_openssl.dll php.ini file. if don't find line php.ini file copy here , paste php.ini , restart apache server. proper solution following warning:
warning : failed connect smtp.gmail.com:465 [smtp: failed connect socket: connection refused (code: -1, response: )]**
Comments
Post a Comment