- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
mail() function in PHP
The mail() function allows in sending emails directly from a script.
Syntax
mail(to,sub,msg,headers,parameters);
Parameters
to − The receiver / receivers of the email
sub − The subject of the email.
msg − The message to be sent.
headers − The additional headers, such as From, Cc, and Bcc.
parameters − The additional parameter to the sendmail program. This was added in PHP 4.0.5.
Return
The mail() function returns the hash value of the address parameter, or FALSE on failure.
Example
The following is an example to send an email −
<?php $msg = "This is demo text!"; $email_msg = wordwrap($msg,40); mail("demo@example.com","Subject Line",$email_msg); ?>
- Related Articles
- Change the Return-Path in PHP mail function
- What is an Electronic Mail (E-Mail)?
- strcmp() function in PHP
- strcoll() function in PHP
- strcspn() function in PHP
- strip_tags() function in PHP
- stripcslashes() function in PHP
- stripos() function in PHP()
- stristr() function in PHP
- stripslashes() function in PHP
- strlen() function in PHP
- strnatcasecmp() function in PHP
- strnatcmp() function in PHP
- strncasecmp() function in PHP
- strncmp() function in PHP

Advertisements