php mailer attachments

Posted by Matthew on Stack Overflow See other posts from Stack Overflow or by Matthew
Published on 2012-06-04T04:10:27Z Indexed on 2012/06/04 4:40 UTC
Read the original article Hit count: 215

Filed under:
|
|
|
|

I have been using this script to send emails to certain staff but because of changes to my system i have to now send attachements with the email and i have tried multipul peices of code to accomplish this but have been unsuccessful... I still recive the email but without the attachement which is quite pointless in this case i have placed the script i am using bellow

i have removed the real addresses i was using and smtp server

    require("PHPMailer/class.phpmailer.php");

$mail = new PHPMailer();

$mail->IsSMTP();    // set mailer to use SMTP
$mail->Host = "SMTP.SErver.com";    

$mail->From = "[email protected]";    
$mail->FromName = "HCSC";  
$mail->AddAddress("[email protected]", "Example"); 
$mail->AddReplyTo("[email protected]", "Hcsc"); 

$mail->WordWrap = 50;    
$mail->IsHTML(false);    

$mail->Subject = "AuthSMTP Test";
$mail->Body    = "AuthSMTP Test Message!";
$mail->AddAttachment("matt.txt"); //this is basicly what i am trying to attach as a test but will be using excel spreadsheets in the production

if(!$mail->Send())
{
   echo "Message could not be sent. <p>";
   echo "Mailer Error: " . $mail->ErrorInfo;
   exit;
}

echo "Message has been sent";

i have also tried a few other emtods of attaching the file but none seem to work any help is greatly appricated

© Stack Overflow or respective owner

Related posts about php

Related posts about html