Jump to content

Recommended Posts

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";
    }
}

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.