Wednesday 27 August 2014

Send Emails Using PHP Scipts

Send Emails Using PHP Scipts is very easy and simple to use.

To Send an email is very simple in php and there are so many ways through wich you can send email.

Here in this code this is very simple and easy example to send email.
Its very useful to clear your concepts.


<?php
    $ToEmail = array( "abc@example.com", "abcd@example.com", "abcde@example.com", "info@example.com");//receivers email
    $EmailSubject = 'Email Subject here';//Subject of email
    $mailheader = "From: ".$_POST["guestemail"]."\r\n".'X-Mailer: PHP/' . phpversion();
$mailheader .= "Reply-To: ".$_POST["guestemail"]."\r\n".'X-Mailer: PHP/' . phpversion();
$mailheader .= "Content-type: text/html; charset=iso-8859-1\r\n".'X-Mailer: PHP/' . phpversion();
$MESSAGE_BODY = "Name: ".$_POST["guestname"]."\n";
$MESSAGE_BODY .= "Email: ".$_POST["guestemail"]."\n";
$MESSAGE_BODY .= "Telephone: ".$_POST["guestelephone"]."\n";
$MESSAGE_BODY .= "Location: ".$_POST["guestloc"]."\n";
$MESSAGE_BODY .= "Message: ".nl2br($_POST["comment"])."\n";
foreach ($ToEmail as $email) {
@mail($email, $EmailSubject, $MESSAGE_BODY, $mailheader);
}
header('location:thanks.html');
};

?>

No comments:

Post a Comment

Printing first 50 Fibonacci numbers Using PHP Program

Fibonacci series is a series of numbers in which each number is the sum of the two preceding numbers. For example. 0 , 1 , 1 , 2 , 3 , 5...