noobe1
asked on
PHPMailer Attachments
Hi Experts
Using the PHPMailer code below, I got the email with messages but not the attachment. Any suggestions?
Thanks
<?php
require("class.phpmailer.p hp");
// Instantiate your new class
$mail = new PHPMailer();
// Now you only need to add the necessary stuff
$mail->AddAddress("txyz@gm ail.com", "xyz");
$mail->AddAttachment("c:/1 1.txt","12 3.txt","ba se64", "application/octet-stream" ); //
$mail->Subject = "Here is the subject";
$mail->Body = "This is the message body";
if(!$mail->Send())
{
echo "There was an error sending the message";
exit;
} else {
echo "Message was sent successfully";
}
?>
Using the PHPMailer code below, I got the email with messages but not the attachment. Any suggestions?
Thanks
<?php
require("class.phpmailer.p
// Instantiate your new class
$mail = new PHPMailer();
// Now you only need to add the necessary stuff
$mail->AddAddress("txyz@gm
$mail->AddAttachment("c:/1
$mail->Subject = "Here is the subject";
$mail->Body = "This is the message body";
if(!$mail->Send())
{
echo "There was an error sending the message";
exit;
} else {
echo "Message was sent successfully";
}
?>
The command to attach a file can be placed anywhere between $mail = new PHPMailer(); and !$mail->Send(); and it's called AddAttachment($path);. This single line will add the attachment to your mail.
$path is the path of the filename. It can be a relative one (from your script, not the PHPMailer class) or a full path to the file you want to attach.
$path is the path of the filename. It can be a relative one (from your script, not the PHPMailer class) or a full path to the file you want to attach.
ASKER
waygood,
I changed the line as you suggested but still not receiving the attachment.
I changed the line as you suggested but still not receiving the attachment.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
$mail->AddAttachment("c:/1