Php Email with example

What is PHP mail?

PHP mail is the built in PHP function that is used to send emails from PHP scripts.

The mail function accepts the following parameters;

  • Email address
  • Subject
  • Message
  • CC or BCC email addresses

Syntax

mail($to_email_address,$subject,$message,[$headers],[$parameters]);

 HERE,

  • “$to_email_address” is the comma separated email address of the mail recipients
  • “$subject” is the email subject
  • “$message” is the message to be sent.
  • “[$headers]” is optional, it can be used to include information such as CC, BCC
    • CC is the acronym for carbon copy. It’s used when you want to send a copy to an interested person i.e. a complaint email sent to a company can also be sent as CC to the complaints board.
    • BCC is the acronym for blind carbon copy. It is similar to CC. The email addresses included in the BCC section will not be shown to the other recipients.
  • “$parameters” is optional. Specifies an additional parameter to the sendmail program (the one defined in the sendmail_path configuration setting). (i.e. this can be used to set the envelope sender address when using sendmail with the -f sendmail option)

Example to Send a simple email:

<?php

// the message
$msg = "Example to send a simple email";
// send email
mail("[email protected]","Your subject",$msg);

?>

The mail method will returns TRUE if the mail was successfully accepted for delivery, FALSE otherwise.

Example to Send an HTML email:

<?php
$to = "[email protected], [email protected]";
$subject = "Example of the HTML email";

$message = "
<html>
<head>
<title>Example of the HTML email</title>
</head>
<body>
<table>
<tr>
<th>Name</th>
<th>Job</th>
</tr>
<tr>
<td>tony stark</td>
<td>Actor</td>
</tr>
</table>
</body>
</html>
";

// Set content-type when sending HTML email
$headers = "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-type:text/html;charset=UTF-8" . "\r\n";

// Headers
$headers .= 'From: <[email protected]>' . "\r\n";
$headers .= 'Cc: [email protected]' . "\r\n";

mail($to,$subject,$message,$headers);
?>

9 Comments

  1. buy cbd oil said:

    I needed to draft you one little observation so as to say thank you as before for those great methods you’ve documented here. It has been certainly pretty generous of people like you to convey freely exactly what a number of people could possibly have made available as an e book to earn some cash for their own end, even more so considering the fact that you could possibly have done it if you ever decided. The ideas also acted like a fantastic way to comprehend other individuals have similar dreams like my own to grasp good deal more on the subject of this issue. I’m sure there are many more fun occasions ahead for individuals that look into your blog post. https://nujemznuedi.online/

    January 7, 2021
    Reply
  2. propecia buy said:

    I’m just commenting to let you be aware of of the exceptional discovery my cousin’s daughter enjoyed going through your blog. She discovered lots of issues, most notably how it is like to have a very effective giving heart to have many others effortlessly gain knowledge of certain extremely tough matters. You really did more than my desires. Many thanks for displaying the helpful, healthy, educational and also easy thoughts on the topic to Gloria. https://harrington-service.com/

    January 8, 2021
    Reply
  3. CELEXA online said:

    My husband and i felt now fortunate Emmanuel could conclude his investigation from your ideas he gained in your site. It’s not at all simplistic just to choose to be giving for free information that most people have been making money from. And we all do understand we have the website owner to be grateful to because of that. All the explanations you’ve made, the easy blog menu, the friendships you assist to create – it’s all awesome, and it’s assisting our son and our family consider that that concept is brilliant, and that’s extraordinarily fundamental. Many thanks for all! https://asendinamoxapine.com/

    January 8, 2021
    Reply
  4. pamelor generic said:

    I’m also commenting to let you be aware of of the cool discovery my child encountered checking your blog. She came to understand a lot of details, including how it is like to have a marvelous coaching heart to get folks easily fully grasp a variety of complicated issues. You actually did more than my desires. I appreciate you for delivering such good, dependable, edifying and also cool guidance on that topic to Ethel. https://pamelornortriptyline.com/

    January 9, 2021
    Reply
  5. doxepin no rx said:

    I precisely desired to say thanks again. I’m not certain the things I might have handled in the absence of the entire points provided by you on such a problem. It has been a very frightening dilemma in my circumstances, however , looking at the skilled mode you processed that made me to jump over fulfillment. I am happier for this help and in addition hope that you know what a great job you are always getting into instructing others through the use of your web blog. I know that you have never encountered all of us. https://sinequandoxepin.com/#

    January 10, 2021
    Reply
  6. https://txt2080.com/ said:

    With respect to the statistical analyses, I have some comments. I would like to point out that ANOVA, the statistical treatment used to compare the incidence of Latin/Greek words in English against Portuguese texts, is not appropriate for the data analyzed.
    The reason is very simple: the sample space of a normal distribution is the whole real set of numbers extending from −∞ to +∞. In contrast, the sample space of a proportion π extends from zero to one. Another point is that the beta distribution is symmetric only when (π = ½ – beta). The beta distribution,
    카지노사이트

    January 16, 2021
    Reply
  7. https://www.vfv79.com/ said:

    The author kindly provided me with the raw data allowing me to reanalyze the results within his focus. I came up with the results shown in Figure 3A which may be advantageously compared with Figure 3 of the article.
    Successful English is my classroom. Every good teacher has classroom rules to make sure that everything that happens in the classroom contributes to the students’ learning. This comment policy is my set of rules for conversations – or comments – here at Successful English. I want every visitor to have a good experience and all of our conversations to be as helpful as possible.
    카지노사이트

    January 16, 2021
    Reply
  8. https://liveone9.com/ said:

    Comments are always welcome on Successful English posts. In fact, they’re encouraged. However, to be sure they contribute to my goals for this site, I will moderate all comments. In other words, I will read and approve them before they appear on the site. If necessary, I will edit them before I approve them. When I edit a comment, I will try hard to keep the writer’s original words and ideas.
    be more than a one-line comment, such as “Great idea!” As much as we all like to receive compliments, this kind of comment does not contribute anything to the overall discussion and often only serves to promote the person leaving the comment. Take time to explain why or how or….
    카지노사이트

    January 16, 2021
    Reply

Leave a Reply

Your email address will not be published. Required fields are marked *