Last active
August 29, 2015 14:00
-
-
Save johnsonch/11192926 to your computer and use it in GitHub Desktop.
A simple PHP email setup
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$top = "<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN""http://www.w3.org/TR/html4/loose.dtd"><html>"; | |
$bottom = "<body></body></html>"; | |
$blank = ' '; | |
$sep = "\r\n"; | |
$subject = $_POST['subject']; | |
$name = $_POST['name']; | |
$email = $_POST['email']; | |
$phone = $_POST['phone']; | |
$message = $_POST['message']; | |
$contact = $_POST['email'] .$blank .$_POST['phone']; | |
$body = $name .$sep .$email .$sep .$phone .$sep .$subject .$sep .$message; | |
$subject = $_POST['subject']; | |
$message = $body; | |
/*********Creating Uniqid Session*******/ | |
$txtSid = md5(uniqid(time())); | |
$headers = ""; | |
$headers .= "From: ".$_POST["email"]."<".$_POST["email"].">\nReply-To: ".$_POST["email"].""; | |
$headers .= "MIME-Version: 1.0\n"; | |
$headers .= "Content-Type: multipart/mixed; boundary=\"".$txtSid."\"\n\n"; | |
$headers .= "This is a multi-part message in MIME format.\n"; | |
$headers .= "--".$txtSid."\n"; | |
$headers .= "Content-type: text/html; charset=utf-8\n"; | |
$headers .= "Content-Transfer-Encoding: 7bit\n\n"; | |
$headers .= $message."\n\n"; | |
/***********Email Attachment************/ | |
if($_FILES["attachment"]["name"] != "") | |
{ | |
$txtFilesName = $_FILES["attachment"]["name"]; | |
$txtContent = chunk_split(base64_encode(file_get_contents($_FILES["attachment"]["tmp_name"]))); | |
$headers .= "--".$txtSid."\n"; | |
$headers .= "Content-Type: application/octet-stream; name=\"".$txtFilesName."\"\n"; | |
$headers .= "Content-Transfer-Encoding: base64\n"; | |
$headers .= "Content-Disposition: attachment; filename=\"".$txtFilesName."\"\n\n"; | |
$headers .= $txtContent."\n\n"; | |
} | |
// @ is for skiping Errors // | |
$flgSend = @mail($to,$subject,null,$headers); | |
mail('person@email.com',$subject, $body); | |
echo ("Thank you for contacting us, " .$name."<br> Your message: <b>"); | |
echo $subject; | |
echo "</b>, has been recieved</br> A response will be sent to you in a timely fashion. <br><br> Have a wonderful day! <br> -AwesomeCO"; | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<form action="contact_response.php" method="post" name="frm_contact" id="frm_contact" enctype="multipart/form-data"> | |
<table width="650" border="0" cellspacing="0" cellpadding="1"> | |
<tr> | |
<td width="8"> </td> | |
<td width="638"><table width="90%" height="224" border="0" cellpadding="1" cellspacing="0"> | |
<tr bgcolor="#FFFFFF"> | |
<td width="22%"><span class="style4 style1 style4 style6">Name</span></td> | |
<td width="78%"><input name="name" type="text" id="name2" size="50"></td> | |
</tr> | |
<tr bgcolor="#FFFFFF"> | |
<td><span class="style4 style1 style4 style6">E-Mail</span></td> | |
<td><input name="email" type="text" id="email" size="50"></td> | |
</tr> | |
<tr bgcolor="#FFFFFF"> | |
<td><span class="style4 style1 style4 style6">Phone</span></td> | |
<td><input name="phone" type="text" id="phone" size="50"></td> | |
</tr> | |
<tr bgcolor="#FFFFFF"> | |
<td><span class="style4 style1 style4 style6">Subject</span></td> | |
<td><input name="subject" type="text" id="subject" onBlur="MM_validateForm('name2','','R','email','','RisEmail','phone','','R','message','','R');return document.MM_returnValue" size="50"></td> | |
</tr> | |
<tr bgcolor="#FFFFFF"> | |
<td><span class="style4 style1 style4 style6">Comments</span></td> | |
<td><textarea name="message" cols="50" rows="5" id="message"></textarea></td> | |
</tr> | |
<tr> | |
<td>Attachment</td> | |
<td><input name="attachment" type="file"></td> | |
</tr> | |
<tr bgcolor="#FFFFFF"> | |
<td colspan="2"><div align="center"> | |
<input type="submit" name="Submit" value="Submit"> | |
</div></td> | |
</tr> | |
</table> <p> </p> | |
</td> | |
</tr> | |
</table> | |
<p> </p> | |
</form> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment