PHP mail() Function – Sending Email
This article explains PHP's mail() function, detailing its parameters, usage cautions, return values, and provides a complete code example for sending an email via SMTP, including formatting of recipient addresses, subject line restrictions, message body limits, and header construction.
PHP's mail() function sends an email.
Parameters
to – Recipient email address or list. Must follow RFC 2822 format, e.g., [email protected] , [email protected], [email protected] , User <[email protected]> , or User <[email protected]>, Another User <[email protected]> .
subject – Email subject. This field must not contain any line‑break characters.
message – Message body. Lines must be separated by a LF (\n) and each line may not exceed 70 characters.
Caution – On Windows, if a line begins with a single period, it may be stripped; replace a single period with two periods to avoid this issue.
Return value – Returns TRUE if the mail was successfully accepted for delivery, otherwise FALSE .
Example
Laravel Tech Community
Specializing in Laravel development, we continuously publish fresh content and grow alongside the elegant, stable Laravel framework.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.