Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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('[email protected]', 'Subject', 'This is a message', array('From' => '[email protected]', 'To' => '[email protected]', '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.

like image 787
Haravikk Avatar asked Jun 20 '26 05:06

Haravikk


1 Answers

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

like image 139
matwr Avatar answered Jun 22 '26 02:06

matwr



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!