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.