I need to send a pdf with mail, is it possible?
$to = \"xxx\";
$subject = \"Subject\" ;
$message = \'Example message with html\';
$header
100% working Concept to send email with attachment in php :
if (isset($_POST['submit'])) {
extract($_POST);
require_once('mail/class.phpmailer.php');
$subject = "$name Applied For - $position";
$email_message = "Thanks for Applying .... ";
$mail = new PHPMailer;
$mail->IsSMTP(); // telling the class to use SMTP
$mail->Host = "mail.companyname.com"; // SMTP server
$mail->SMTPDebug = 0;
$mail->SMTPAuth = true;
$mail->SMTPSecure = "ssl";
$mail->Host = "smtp.gmail.com";
$mail->Port = 465;
$mail->IsHTML(true);
$mail->Username = "info@companyname.com"; // GMAIL username
$mail->Password = "mailPassword"; // GMAIL password
$mail->SetFrom('info@companyname.com', 'new application submitted');
$mail->AddReplyTo("name@yourdomain.com","First Last");
$mail->Subject = "your subject";
$mail->AltBody = "To view the message, please use an HTML compatible email viewer!"; // optional, comment out and test
$mail->MsgHTML($email_message);
$address = 'info@companyname.com';
$mail->AddAddress($address, "companyname");
$mail->AddAttachment($_FILES['file']['tmp_name'], $_FILES['file']['name']); // attachment
if (!$mail->Send()) {
/* Error */
echo 'Message not Sent! Email at info@companyname.com';
} else {
/* Success */
echo 'Sent Successfully! Check your Mail';
}
}
I used this code for google smtp mail sending with Attachment....
Note: Download PHPMailer Library from here -> https://github.com/PHPMailer/PHPMailer