mail() function in PHP

王林
Release: 2023-09-12 14:38:02
forward
1428 people have browsed it

mail() function in PHP

The mail() function allows sending emails directly from scripts.

Syntax

mail(to,sub,msg,headers,parameters);
Copy after login

Parameters

  • to - Recipient of the email

  • < p>sub - The subject 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.

Return

The mail() function returns the hash value of the address parameter, and returns FALSE on failure.

Example

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);
?>
Copy after login

The above is the detailed content of mail() function in PHP. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:tutorialspoint.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!