尝试使用在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 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.