PHP Programing language

Sending Emails in PHP
Previous Home Next

Sending Emails in Php

Sending Emails in Php is used to send emails directly from a script. This is done by using the mail() function in php which allows you to send emails.

Syntax:
mail(to,subject,message,headers,parameters);

In the above syntax, "to" specifies the receiver / receivers of the email, "subject" specifies the subject of the email, "message" defines the message to be sent, "headers" specifies additional headers, like From, Cc, and Bcc and "parameters" specifies an additional parameter to the sendmail program.

Example:

<?php
   $to = "xyz@anydomain.com";
   $subject = "-------Subject-------";
   $message = "-------Message-------";
   $header = "From:xyz@anydomain.com \r\n";
   $retval = mail ($to,$subject,$message,$header);
   if( $retval == true )  
   {
      echo "Message sent Successfully......!!!!";
   }
   else
   {
      echo "Message could not be sent...!!!!!";
   }
?>

Output:

Message sent Successfully......!!!!
Previous Home Next

Tolal:0 Click:

Show All Comments

Did not find what you were looking for leave your name and message. We will revert within 24 hours
Name:
eMail:
Comment / Feedback: