Skip to content

Instantly share code, notes, and snippets.

@galaakk
Created September 8, 2012 20:17
Show Gist options
  • Save galaakk/3679376 to your computer and use it in GitHub Desktop.
Save galaakk/3679376 to your computer and use it in GitHub Desktop.
PHP : Simple e-mail send
<?php
$mail_to = 'myname@mydomain.com';
$name = $_POST['sender_name'];
$mail_from = $_POST['sender_email'];
$message = $_POST['sender_message'];
$subject = 'Subject ' . $name;
$body_message = 'From: ' . $name . "\r\n";
$body_message .= 'E-mail: ' . $mail_from . "\r\n";
$body_message .= 'Message: ' . $message;
$headers = 'From: ' . $mail_from . "\r\n";
$headers .= 'Reply-To: ' . $mail_from . "\r\n";
$mail_sent = mail($mail_to, $subject, $body_message, $headers);
if ($mail_sent == true){ ?>
<script language="javascript" type="text/javascript">
alert('Merci pour votre message. Nous vous recontacterons le plus rapidement possible.');
window.location = 'index.html#formulaire';
</script>
<?php } else { ?>
<script language="javascript" type="text/javascript">
alert('Message not sent. Please, notify site administrator myadmin@mydomain.com');
window.location = 'index.html#formulaire';
</script>
<?php
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment