Sending email from localhost in php in windows

核能气质少年 提交于 2019-12-06 16:34:32

Try using SMTP server with gmail.

ini_set("SMTP","ssl://smtp.gmail.com");
ini_set("smtp_port","465");

or else there are many PHP mailer library. which simplifies things for you and makes it so easier to use. my fav is swift mailer. the best part about is you don't have to mess with your core php configuration file and the documentation too is very easy to read.

for example if you want to send a mail using PHP's swift mailer library it is as simple as.

require_once 'lib/swift_required.php';

// Create the Transport
$transport = Swift_SmtpTransport::newInstance('smtp.example.org', 25)
  ->setUsername('your username')
  ->setPassword('your password');

// Create the Mailer using your created Transport
$mailer = Swift_Mailer::newInstance($transport);

// Create a message
$message = Swift_Message::newInstance('Wonderful Subject')
  ->setFrom(array('john@doe.com' => 'John Doe'))
  ->setTo(array('receiver@domain.org', 'other@domain.org' => 'A name'))
  ->setBody('Here is the message itself');

// Send the message
$result = $mailer->send($message);

you can refer the documentation for more information on the official website http://swiftmailer.org/docs

Shouldn't SMTP point to your SMTP server? (I am assuming smtp.tools.sky.com is your provider). Also sendmail_from should be a correct emailaddress.

Also note some mail provders block email sent from dynamic ip adresses.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!