godleydesign Posted April 15, 2013 Share Posted April 15, 2013 Hi I've wrote a small bit of code which basiclly sends out an email with an jpg attached, nothing fancy. The code works fine when not included within a function. However, as soon as it's included within a function the email still sends.. however no jpg is attached. The code below is it within a function. Any ideas why is it not adding the attachment when inside a function? function resendOrder() { require_once('OrderMailer/class.phpmailer.php');// need this to send email $mail = new PHPMailer(); // HTML body $body = "Testing"; // And the absolute required configurations for sending HTML with attachement $mail->From = "mark@******.co.uk"; $mail->AddAddress("mark@******.co.uk", "My-webpage Website"); $mail->Subject = "test for phpmailer-3"; $mail->MsgHTML($body); $mail->AddAttachment("ploxy.jpg"); if(!$mail->Send()) { echo "There was an error sending the message"; exit; } else{ echo "Message was sent successfully"; } } Quote Link to comment https://forums.phpfreaks.com/topic/276973-php-mailer-no-attachement-when-within-function/ Share on other sites More sharing options...
godleydesign Posted April 15, 2013 Author Share Posted April 15, 2013 Managed to resolve this myself. Quote Link to comment https://forums.phpfreaks.com/topic/276973-php-mailer-no-attachement-when-within-function/#findComment-1424938 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.