All TalkersCode Topics

Follow TalkersCode On Social Media

PHP Email Sending

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


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


<title>Sending email using PHP</title>


   $to = "";
   $subject = "This is subject";
   $message = "This is simple text message.";
   $header = " \r\n";
   $retval = mail ($to,$subject,$message,$header);
   if( $retval == true )  
      echo "Message sent successfully...";
      echo "Message could not be sent...";

❮ PrevNext ❯