Home > Article > Backend Development > mail() function in PHP
The mail() function allows sending emails directly from scripts.
mail(to,sub,msg,headers,parameters);
to - Recipient of the email
msg - The message to send.
headers - Additional headers such as From, Cc, and Bcc.
Parameters - Additional parameters for the sendmail program. This was added in PHP 4.0.5.
The mail() function returns the hash value of the address parameter, and returns FALSE on failure.
The following is an example of sending an email -
<?php $msg = "This is demo text!"; $email_msg = wordwrap($msg,40); mail("demo@example.com","Subject Line",$email_msg); ?>
The above is the detailed content of mail() function in PHP. For more information, please follow other related articles on the PHP Chinese website!