sending an email through php

sending an email through php

Sending An E-mail

Before sending your mail, if you are using variables, you must, of course, set up the variable content beforehand. Here is some simple code for sending a message:

$to = “[email protected]”;
$subject = “PHP Is Great”;
$body = “PHP is one of the best scripting languages around”;
$headers = “From: [email protected]\n”;
mail($to,$subject,$body,$headers);
echo “Mail sent to $to”;

This code will acutally do two things. Firstly it will send a message to [email protected] with the subject ‘PHP Is Great’ and the text:

PHP is one of the best scripting languages around

and the e-mail will be from [email protected] It will also output the text:

Mail sent to [email protected]

to the browser

Sharing

Leave your comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.