Binod's Blog

E-mail Script in PHP

by on Sep.18, 2011, under PHP, Web Designing

This is an example of simple e-mail script for PHP that can be used.

<?php
//define the receiver of the email
$to = ‘someone@somemail.com’;
//define the subject of the email
$subject = ‘Test email’;
//define the message to be sent. Each line should be separated with \n
$message = “Hello World!\n\nThis is my first mail.”;
//define the headers we want passed. Note that they are separated with \r\n
$headers = “From: webmaster@example.com\r\nReply-To: webmaster@example.com”;
//send the email
$mail_sent = mail( $to, $subject, $message, $headers );
//if the message is sent successfully print “Mail sent”. Otherwise print “Mail failed”
if($mail_sent){
print “Mail sent”;
}
else {
print “Mail failed.”;
}

?>

:

Looking for something?

Use the form below to search the site:

Still not finding what you're looking for? Drop a comment on a post or contact us so we can take care of it!

Blogroll

A few highly recommended websites...