Sending emails in php

Sending email functionality is now a must feature in almost every website. Now its up to you in which module you are allowing visitor to send emails.

The php mail() is used to send emails. It normally takes five parameters, among these three parameters are required. The five parameters are as follows

  1. to (Required. Specify the email address of reciever)
  2. subject (Required. Specify the subject of the email)
  3. message(Required. Specify the message of the email)
  4. headers(Optional. Specify the other additional information like from.cc, bcc etc
  5. parameters(Specify additional parameter)

PHP Simple Email Program

The simplest way for email to be send is a text based email

$to="abc@yahoo.com";

$subject="Testing email in php";

$message="I just want to test the email functionality in php";

$from="xyz@gmail.com";

$headers="from:$from";

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

echo "Email sent successfully";

0 comments: