Saturday, February 19, 2011

your emailer your name reply to attach file subject plain text php?

There's a function included in PHP to send emails: mail()
Look here for more information on mail() and for references of all other PHP functions.

Simple example code:

contact_form.html:

(Toggle Plain Text)



Your name:

Your email:

Your message:







Your name:

Your email:

Your message:






contact_form.php

(Toggle Plain Text)
Email: " . $reply . "
Message:

" . $message . "

";

//Send email - mail($toAddress, $subject, $message) - and check it sends
//without error, if the function returns false then handle the error
if(mail("yourEmail@example.com","Stuff from website form",$emailString)){
echo("Yay, message sent successfully.");
}
else{
echo("Boo, something went wrong!");
}

?>Email: " . $reply . "
Message:

" . $message . "

";

//Send email - mail($toAddress, $subject, $message) - and check it sends
//without error, if the function returns false then handle the error
if(mail("yourEmail@example.com","Stuff from website form",$emailString)){
echo("Yay, message sent successfully.");
}
else{
echo("Boo, something went wrong!");
}

?>

Been a while since I've done any PHP, but that should be correct.

No comments:

Post a Comment