PHP Mail Attachment – Php Send Email File-Images Attachments

PHP Mail Attachment – Php Send Email File-Images Attachments

In this Post We Will Explain About is PHP Mail Attachment – Php Send Email File-Images Attachments 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 Send Email with Attachment in PHPExample

In this post we will show you Best way to implement php send email with attachment example, hear for how to create php based email form with file attachmentwith Download .we will give you demo,Source Code and examples for implement Step By Step Good Luck!.

PHP mail attachment : structure

index.php
do_email_submit.php
contact_validation.js

Phase 1 : Create Email Form HTML index.php

	

Example: simple Send Email template with Attachment in PHP

Phase 2: Validate Email Form contact_validation.js

$('document').ready(function() {
(function() {
	$('form').ajaxForm({
		beforeSubmit: function() {
		$("#submit_email_form").validate({
			rules: {
				client_name: {
				required: true,
				minlength : 3
				},
				client_email: {
				required: true,
				email: true
				},
				data_attach: {
				required: true
				},
				comments: {
				required: true
				}
			},
			messages: {
			client_name: {
			required:"Please enter client_name",
			minlength: "Please enter a valid client_name"
			},
			client_email:{
			required: "Please enter your client_email",
			minlength: "Please enter a valid client_email address",
			},
			data_attach: "Please Choose data_attach Images / files",
			comments: "Please enter comments"
			},
		});
		var flag= $('#submit_email_form').valid();
		if(!flag){
		return false;
		}
	},
	complete: function(xhr) {
	$("#submit_email_form").addClass("hidden");
	$("#success_message").removeClass("hidden");
	}
	});
})();
});

Phase 3: Implement simple Email Send Logic with Attachment some File or Images using PHPMailer(do_email_submit.php)

FromName = $_POST['client_name'];
		$to_email = $_POST['client_email'];
		$mail->AddAddress($to_email);
		$mail->From = "[email protected]";
		$mail->Subject = "Test Client-Email Send using PHP and jquery ajax";
		$contentbody = "
This is a first test email
client_name : ".$_POST['client_name']."
client_email : ".$_POST['client_email']."
comments : ".$_POST['comments']."
"; $contentbody = preg_replace('/\\\\/','', $contentbody); $mail->MsgHTML($contentbody); $mail->IsSendmail(); $mail->AddReplyTo("[email protected]"); $mail->AltBody = "To view the all comments, please simple use an HTML all elements compatible email simple viewer!"; $mail->WordWrap = 90; $mail->AddAttachment($_FILES['data_attach']['tmp_name'], $_FILES['data_attach']['name']); $mail->IsHTML(true); $mail->Send(); echo 'The comments has been sent.'; } } catch (phpmailerException $e) { echo $e->errorMessage(); } ?>

Example

I hope you have Got What is send email with attachment in php using phpmailer 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.

Leave a Comment