How to send file as an attachment with phpmailer
Posted: Sat Apr 25, 2009 3:37 am
Hello
I am using PHPMAILER library to send email with attachment fro my website.
Actually there is a form on my website, and a browser button. User come onto my website and use the "browse" button to select from his PC. And fianlly press the submit button of the form. In that case i receive the email but not the complete attachment.
Is there any specific way to do you. I just want that whatever files user upload from that browse button I got that in my email with the attachement.
here is my code
Kindly help me that how can i fix that problem.
Thanks
I am using PHPMAILER library to send email with attachment fro my website.
Actually there is a form on my website, and a browser button. User come onto my website and use the "browse" button to select from his PC. And fianlly press the submit button of the form. In that case i receive the email but not the complete attachment.
Is there any specific way to do you. I just want that whatever files user upload from that browse button I got that in my email with the attachement.
here is my code
Code: Select all
$mailcomp = & new PHPMailer();
$mailcomp->From = "aaa@aaa.com";
$mailcomp->FromName = "Digitizing Art";//
$mailcomp->Host = "Digitizing Art";
$mailcomp->Mailer = "sendmail";
$mailcomp->Sender = "aaa@aaa.com";
$mailcomp->Subject = "Digitizing Art Order Details";
// HTML body
$body = "Hello <font size=\"4\">" . $row["full_name"] . "</font>, <p>";
$body .= "<i>Your</i> personal photograph to this message.<p>";
$body .= "Sincerely, <br>";
$body .= "phpmailer List manager";
// Plain text body (for mail clients that cannot read HTML)
$text_body = "Hello " . $row["full_name"] . ", \n\n";
$text_body .= "Your personal photograph to this message.\n\n";
$text_body .= "Sincerely, \n";
$text_body .= "phpmailer List manager";
$mailcomp->Body = $body;
$mailcomp->AltBody = $text_body;
$mailcomp->AddAddress("aaa@aaa.com");
$mailcomp->AddStringAttachment($_REQUEST["fileField1"], "YourPhoto.jpg");
if(!$mailcomp->Send())
echo "There has been a mail error sending" ;
// Clear all addresses and attachments for next loop
$mailcomp->ClearAddresses();
$mailcomp->ClearAttachments();
Thanks