Join TalkersCode Now !

Get Latest Tutorials And Links On Web Development
And Get Existing Offers Via Email

PHP Email Sending

PHP Email Sending

All th process to send emails is very easy with the help of PHP.It uses mail() function to send emails.


Syntax


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

Code Explanation

  • to the value of to is the email address of the reciever.

  • subject the value of subject is the subject of the email.

  • message the value of message is the main content of the email.

  • header It is optional the value of header like From, Cc, and Bcc. The additional headers should be separated with a CRLF (\r\n).

  • parameters It is optional specifies an additional parameter to the sendmail program.


Simple Example To send emails


<html>

<head>
<title>Sending email using PHP</title>
</head>

<body>

<?php
   $to = "xyz@somedomain.com";
   $subject = "This is subject";
   $message = "This is simple text message.";
   $header = "From:abc@somedomain.com \r\n";
   $retval = mail ($to,$subject,$message,$header);
   if( $retval == true )  
   {
      echo "Message sent successfully...";
   }
   else
   {
      echo "Message could not be sent...";
   }
?>

</body>
</html>
PrevNext

Join Us With Our 21000+ Subscribers And Get Our Latest Tutorials Update Via Email

Are You Starting A New Blog
Do You Want Best Web Hosting?

Try World's Best Web Hosting Provider BlueHost
At Just $3.95/mo

Hurry Up! Limited Time Offer

Yes, I Want To Check Out BlueHost

Check The World's Best SEO And All-In-One Marketing Toolkit
For Digital Marketing Professionals SEMRUSH

Check Out SEMRUSH