Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How does PHP's `mail` work?

Tags:

php

email

PHP's mail function seems to deliver mail on a clean system, with no apparent configuration done by the administrator or webmaster (no SMTP configuration in php.ini, etc.). How does the mail function deliver mail to a remote server?

like image 234
Tom Marthenal Avatar asked Aug 04 '12 20:08

Tom Marthenal


People also ask

How do I know if PHPMailer is working?

to check if it is sending mail as intended; <? php $email = "[email protected]"; $subject = "Email Test"; $message = "this is a mail testing email function on server"; $sendMail = mail($email, $subject, $message); if($sendMail) { echo "Email Sent Successfully"; } else { echo "Mail Failed"; } ?>

How can I tell if an email is sent in PHP?

Well mail() simply returns a boolean value depending on whether the mail was successfully accepted for delivery. From the php.net site: Returns TRUE if the mail was successfully accepted for delivery, FALSE otherwise.


1 Answers

On *nix it invokes the sendmail binary, which then uses the mail configuration to route the email. On Windows, it sends to a SMTP server. In both cases the sysadmin sets up the mail system.

like image 162
Ignacio Vazquez-Abrams Avatar answered Oct 11 '22 11:10

Ignacio Vazquez-Abrams