<?phpfunction mail_attachment($filename, $path, $mailto, $from_mail, $from_name, $replyto, $subject, $message) {$file = $path.$filename;$file_size = filesize($file);$handle = fopen($file, "r");$content = fread($handle, $file_size);fclose($handle);$content = chunk_split(base64_encode($content));$uid = md5(uniqid(time()));$header = "From: ".$from_name." <".$from_mail.">\r\n";$header .= "Reply-To: ".$replyto."\r\n";$header .= "MIME-Version: 1.0\r\n";$header .= "Content-Type: multipart/mixed; boundary=\"".$uid."\"\r\n\r\n";$header .= "This is a multi-part message in MIME format.\r\n";$header .= "--".$uid."\r\n";$header .= "Content-type:text/plain; charset=iso-8859-1\r\n";$header .= "Content-Transfer-Encoding: 7bit\r\n\r\n";$header .= $message."\r\n\r\n";$header .= "--".$uid."\r\n";$header .= "Content-Type: application/octet-stream; name=\"".$filename."\"\r\n";$header .= "Content-Transfer-Encoding: base64\r\n";$header .= "Content-Disposition: attachment; filename=\"".$filename."\"\r\n\r\n";$header .= $content."\r\n\r\n";$header .= "--".$uid."--";// Messages for testing only, nobody will see them unless this script URL is visited manuallyif (mail($mailto, $subject, "", $header)) {echo "Message sent!";} else {echo "ERROR sending message.";}}// Only accept POSTs from authenticated sourceif ($_POST['HandshakeKey'] != 'secret-handshake-key') {echo "<h1>You are not who you say you are, mister man.</h1>";die();}// EDIT FROM HERE DOWN TO// CUSTOMIZE EMAIL// File to attach$my_file = "whitepaper.doc";$my_path = ''; // $_SERVER['DOCUMENT_ROOT']."/your_path_here/";// Who email is FROM$my_name = "Your Name (or) Your Business";$my_mail = "youremail@yourbusiness.com";$my_replyto = "youremail@yourbusiness.com";// Whe email is going TO$to_email = $_POST['Field103']; // Comes from Wufoo WebHook// Subject line of email$my_subject = "Your file has arrived!";// Content of email message (Text only)$requester = $_POST['Field101']; // Comes from Wufoo WebHook$message = "Hey $requester,Your custom email messagegoes here";// Call function to send emailmail_attachment($my_file, $my_path, $to_email, $my_mail, $my_name, $my_replyto, $my_subject, $message);?>
Friday, May 22, 2015
How to Send a Confirmation Email with a File Attachment
Subscribe to:
Post Comments (Atom)
Popular Posts
-
Variables are important in every programming language — and it’s no different in PHP. Variables give developers the possibility of temp...
-
What? Hide the .php extension of your PHP files in the URL of your site address. Instead of: http://www.example.com/page.php Visitors to ...
-
Questions : 1 Who is the father of PHP ? Answers : 1 Rasmus Lerdorf is known as the father of PHP. Questions : 2 What is the...
-
Change Db settings here C:\xampp\htdocs\modx\core\xpdo\xpdo.class Line 2920 $this->config['dsn']= $dsn; $this->con...
-
<form action="" name="" method="post"> <p><b>user:</b> <input type="text...
-
Redirection is process of forwarding one URL to a different URL. There are three main kinds of redirects online; 301, 302 and meta refres...
-
Questions : 1 What is database or database management systems (DBMS)? and - What’s the difference between file and database? Can files...
-
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.5.2/jquery.min.js"></script...
-
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>Add More Elements...
No comments:
Post a Comment
Thank you for your Comment....