MAC OS X Configuration PHP Mail Environment tutorial

Source: Internet
Author: User
Tags configuration php nginx server


We will implement the following function points:

How to get your Mac computer to become a localhost mail server (local mail servers) that can send mail directly;
The functions of PHP mail () function are implemented in Mac OS X system;


Modify PHP's main profile php.ini file to open the Send mail function for PHP mail () functions under Unix-like systems:

The code is as follows Copy Code

Sendmail_path = "Env-i/usr/sbin/sendmail-t-I."

Then restart the Apache server or Nginx server, and so on.

Open Mail Service
Outgoing messages are implemented primarily by the Mail Transfer agent (MTA) message transfer agent, and the commonly used MTA has postfix,sendmail.

However Mac OS X system is pre-installed with the Postfix service, we don't need to install it again, just open it ok.

The code is as follows Copy Code

$ sudo postfix start
Postfix/postfix-script:starting the Postfix mail system

To see if Postfix is started, just check to see if the process was created.

The code is as follows Copy Code

lixi$ Ps-ef | grep postfix
0 45793 1 0 5:50 pm?? 0:00.03/usr/libexec/postfix/master

See where postfix is installed?

The code is as follows Copy Code

$ which postfix
/usr/sbin/postfix

Test whether Postfix can successfully send mail

The code is as follows Copy Code

$ date | Mail-s Testing name@gmail.com

View Mail Send queues

The code is as follows Copy Code

$ mailq
-queue id-–size–--arrival Time —--Sender/recipient ——-
9e7d8276e30* 369 Sun Feb 18:39:42 user@userdemacbook-pro.local
Name@gmail.com

Open Gmail to see if there are any messages with testing headers.


Note: Messages are most likely to be in spam, and localhost e-mail addresses are generally considered junk mail.

I received an email stating that Postfix was already working.

PHP mail () function test message

The code is as follows Copy Code
<?php
$send = Mail (' name@gmail.com ', ' My Subject ', ' The Test Mail ');
if ($send) {
Echo ' true ';
}
else {
echo ' false ';
}

Quickly follow this article and let your Mac computer easily send mail.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.