尝试使用在Microsoft的SMTP服务器(@ live.com,@ outlook.com等)上配置的电子邮件地址通过PHP发送电子邮件

尝试使用在Microsoft的SMTP服务器(@ live.com,@ outlook.com等)上配置的电子邮件地址通过PHP发送电子邮件

问题描述:

I'm trying to send email via a PHP script. Here's the line of code that is supposed to send the email:

mail($owner_email, $subject, $messageBody, $headers)

Here are what my variables are set to:

$owner_email = mike@mikemarks.net

$subject = "Blah"

$messageBody = "Blah"

The email address, mike@mikemarks.net, is configured on Microsoft's email servers. I have email sending and receiving from their servers - smtp.live.com (for outgoing). For some reason, the above line of code isn't sending an email to mike@mikemarks.net.

QUESTIONS:

  1. Are there certain email services that won't work with PHP's email functionality, such as Microsoft's?
  2. I understand I can't set SMTP settings in PHP - does this mean that PHP uses its own SMTP server?

我正在尝试通过PHP脚本发送电子邮件。 以下是应该发送电子邮件的代码行: p>

mail($ owner_email,$ subject,$ messageBody,$ headers) code> p> \ n

以下是我的变量设置为: p>

$ owner_email code> = mike@mikemarks.net code> p>

$ subject code> =“Blah” p>

$ messageBody code> =“Blah” p>

电子邮件地址 mike@mikemarks.net code>在Microsoft的电子邮件服务器上配置。 我有他们的服务器发送和接收电子邮件 - smtp.live.com(传出)。 出于某种原因,上述代码行未向 mike@mikemarks.net code>发送电子邮件。 p>

问题 strong>: p>

  1. 是否有某些电子邮件服务不适用于PHP的电子邮件\ 功能,如微软的? li>
  2. 据我所知,我无法在PHP中设置SMTP 设置 - 这是否意味着PHP使用自己的SMTP服务器? li> ol> div>

PHP uses the SMTP server specified in the php.ini. Most often, it's localhost, which uses the hosting server's own SMTP server. Check the response of the mail function (true/false) to make sure that the email is going through, and check the mail log of the server to see if there's an error there. You can see http://www.phpclasses.org/blog/package/9/post/1-Sending-email-using-SMTP-servers-of-Gmail-Hotmail-or-Yahoo-with-PHP.html for information how to use Hotmail as the SMTP server.

No. PHP does not have its own smtp server. It either uses the system default one (unix-ish systems) or the one configured via the smtp_* .ini directives (Windows).

If you're on a unixish host and want to use external SMTP servers, then you'll have to either use a real library, e.g. phpmailer or swiftmailer, to connect directly to the external servers. Or you configure the local smtp server to act as a forwarding-only server which passes any local-sent emails directly to the external ones.