在Windows中从php发送电子邮件从localhost [英] Sending email from localhost in php in windows

查看:152
本文介绍了在Windows中从php发送电子邮件从localhost的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用这个非常小的代码来测试电子邮件是否到达电子邮件目的地:

I am using this very tiny piece code to test whether an email reaches the email destination:

<?php
  mail('woodsy013@hotmail.com','Test mail','The mail function is working!');
  echo 'Mail sent!';
?>

但它似乎没有工作。我正在使用WAMP。我已经安装了一个免费的SMTP服务器。而我的php.ini文件被配置成如下:

But it doesnt seem to be working. I am using WAMP. I have installed a free SMTP server. And my php.ini file is configured to the following:

[mail function]
; For Win32 only.
; http://php.net/smtp
SMTP = smtp.tools.sky.com
; http://php.net/smtp-port
smtp_port = 25

; For Win32 only.
; http://php.net/sendmail-from
sendmail_from = you@yourdomain

我似乎没有收到一封电子邮件至woodsy130@hotmail.com遵循我提到的行动。

I dont seem to be receiving an email to woodsy130@hotmail.com following the actions I have mentioned.

我收到此错误:

Warning: mail() [function.mail]: SMTP server response: 530 5.7.0 
Must issue a STARTTLS command first. ff2sm10904265wib.9 in 
C:\wamp\www\Derrysgc2\pages\pages\mailtest.php on line 2

任何建议?

推荐答案

尝试使用带有gmail的SMTP服务器。 >

Try using SMTP server with gmail.

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

否则有很多PHP邮件库。这简化了你的使用,并使它更容易使用。我的最爱是快递邮件。最好的部分是您不必混淆您的核心php配置文件,并且文档也很容易阅读。

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.

例如,如果要发送使用PHP的快速邮件库的邮件就是这样简单。

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);

您可以参考文档了解官方网站的更多信息 http://swiftmailer.org/docs

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

这篇关于在Windows中从php发送电子邮件从localhost的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆