简体   繁体   中英

How Does PHP Send Mail Using mail() Without sendmail?

Okay, so I have a simple script that sends an e-mail via PHP's mail function like so:

<?php mail('foo@example.org', 'Subject', 'This is a message', array('From' => 'bar@example.org', 'To' => 'foo@example.org', 'Subject' => 'This is a message')); ?>

It works perfectly when run on a Synology DS212j (a Linux-based NAS using BusyBox for most common shell commands), however as far as I can tell there is no instance of sendmail anywhere that I can find, and the BusyBox sendmail isn't enabled. In fact, if I use ini_get("sendmail_path") then a value of " -t -i" is returned.

There's an environment variable of MAIL=/var/mail/root but this doesn't to do anything either (there is no /var/mail ).

So I'm at a complete loss as to how PHP is actually sending its e-mail, so I'm hoping someone might know. I'm having trouble going through sendmail for PHP on another platform (on the same network sigh ) so if I can use the same mechanism as my NAS then it could make things easier.

If you have qmail or postfix on your system and they are configured with sendmail wrappers, then PHP can be configured to work with these. Otherwise sendmail binaries must be on the system for php to send email using mail() function.

reference : http://php.net/manual/en/mail.requirements.php

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM