PHP Send HTML Email File Attachment Using PHPs mail
In this Post We Will Explain About is PHP Send HTML Email File Attachment Using PHPs mail With Example and Demo.Welcome on Pakainfo.com – Examples, The best For Learn web development Tutorials,Demo with Example! Hi Dear Friends here u can know to How to create PHP based email form with file attachmentExample
In this post we will show you Best way to implement How to Send a Confirmation Email with a File Attachment, hear for Php Send Email with Attachment – Sending Mailwith Download .we will give you demo,Source Code and examples for implement Step By Step Good Luck!.
PHP – send email with attachment file
PHP simple send mail with attachment script. This simple or custom function or source code PHP mail attachment script is simple able to send a text or plain text email send message as well as with a single data path attachment file.Below is an simple example on how we use this function to as send an simple email message with one some attached live24u.pdf file:Include the simple main script file — require_once(‘path/to/file/class.phpmailer.php’); as well as Download the PHPMailer libs or script source code from here: http://github.com/PHPMailer/PHPMailer
Source code : PHP mail attachment script
$my_file = "live24u.pdf"; // Pakainfo.com attachment file name $path = "Your folder name"; //Pakainfo.com path of attachment file $user_name = "Your Usrename"; //Pakainfo.com user name $mail_to = "live[email protected]"; //Pakainfo.com to eamil $mail_sub = "Notification of attachment for user"; //Pakainfo.com subject of eamil $body_text = "Hello ".$user_name.",\nThis demo message with file attachment. You will be notified when their review has been completed.\n Regard \n live24u Team"; $attachment_file = $path . "/" . $my_file; // path of file $attachment_file_size = filesize($attachment_file); $email_handle = fopen($attachment_file, "r"); $content = fread($email_handle, $attachment_file_size); fclose($email_handle);// file close of email handle $content = chunk_split(base64_encode($content)); $myLivetime = md5(time());// a random hash will be necessary to send mixed content // carriage return type (we use a PHP end of line constant) $mail_seol = PHP_EOL; $body_message = $body_text; // main header (multipart mandatory) $mail_header = "From: Pakainfo.com Team <[email protected]>" . $mail_seol; //Pakainfo.com sender eamil detail $mail_header .= "MIME-Version: 1.0" . $mail_seol;//MIME-Version $mail_header .= "Content-Type: multipart/mixed; boundary=\"" . $myLivetime . "\"" . $mail_seol;//Content-Type $mail_header .= "Content-Transfer-Encoding: 7bit" . $mail_seol;//Content-Transfer-Encoding $mail_header .= "This is a MIME encoded message." . $mail_seol; //Pakainfo.com eamil message $mail_header .= "--" . $myLivetime . $mail_seol; $mail_header .= "Content-Type: text/plain; charset=\"iso-8859-1\"" . $mail_seol; $mail_header .= "Content-Transfer-Encoding: 8bit" . $mail_seol; $mail_header .= $body_message . $mail_seol; //Pakainfo.com attachment $mail_header .= "--" . $myLivetime . $mail_seol; $mail_header .= "Content-Type: application/octet-stream; name=\"" . $my_file . "\"" . $mail_seol; $mail_header .= "Content-Transfer-Encoding: base64" . $mail_seol; $mail_header .= "Content-Disposition: attachment" . $mail_seol; $mail_header .= $content . $mail_seol; $mail_header .= "--" . $myLivetime . "--"; mail($mail_to, $mail_sub, ", $mail_header); //SEND Mail TO USER
About PHP’s native mail() function
The attachment simple file has to be PHP uploaded first or we can use a simple file which already here exists on your any linux file or folder web server
I hope you have Got What is Sending HTML-email with Attachment Using PHP’s mail() Function And how it works.I would Like to have FeadBack From My Blog(Pakainfo.com) readers.Your Valuable FeadBack,Any Question,or any Comments abaout This Article(Pakainfo.com) Are Most Always Welcome.