2

HI im trying to send multiple attachment with php mailer but only one attachment being sent even both files are uploaded and path are correct below is code. in second iteration $mail->addAttachment return false.

if  (is_array( $email_attachment )) {

    foreach ($email_attachment as $attachment ) {

        $mail->addAttachment($attachment ); 

        var_dump($attachment);
        echo '<br/>';  

        var_dump($mail->addAttachment($attachment));
        echo '<br/>'; 
    }

     die();
}

dump result.

string(62) "D:\htdocs\express-english/wp-content/uploads/2016/10/23882.jpg" 
bool(true) 
string(63) " D:\htdocs\express-english/wp-content/uploads/2016/10/97778.jpg" 
bool(false)
Shahid Chaudhary
  • 890
  • 3
  • 14
  • 25
  • 2
    this is not seems correct "D:\htdocs\express-english/wp-content/uploads/2016/10/23882.jpg" check attachment url:- http://stackoverflow.com/a/27296406/4248328 . you can check your code too – Alive to die - Anant Oct 05 '16 at 08:21

1 Answers1

1

Your 2nd string contains a space in front of it

string(63) " D:\htdocs\express-english/wp-content/uploads/2016/10/97778.jpg" 

you should trim that with

$attachment = trim($attachment);

before using $mail->addAttachment