Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    Senior Coder NancyJ's Avatar
    Join Date
    Feb 2005
    Location
    Bradford, UK
    Posts
    3,172
    Thanks
    19
    Thanked 65 Times in 64 Posts

    Multiple Email Attachments

    I'm trying to send 2 attachments with an email but only the first one comes through - I've googled til my fingers turned numb and all I find is questions, no solutions (just use PEAR/phpMailer is not a solution)

    This is my code
    PHP Code:
    $invoice_data chunk_split(base64_encode(file_get_contents($invoice)));
                        
    $encoded_data chunk_split(base64_encode(file_get_contents($checkin)));
                    
                    
                        
    $boundary "------=_NextPart_000_13e7_6608_6142";

                        
    $headers "From:Reservations<ops@everythingcannes.com\r\n";
                    
                        
    $headers .= "Mime-Version: 1.0\r\n";
                        
    $headers .= 'Content-Type: multipart/mixed'.'; boundary="'$boundary .'"' "\r\n\r\n";
                        
    $headers2 .= "This is a multi-part message in MIME format.\r\n\r\n";
                        
    $headers2 .= "--$boundary\r\n";
                    
                        
    $headers2 .= "Content-Type: text/html; charset=iso-8859-1; format=flowed\r\n";
                        
    $headers2 .= "Content-Transfer-Encoding: 7bit\r\n\r\n";
                    
                        
    $headers2 .= "$content\r\n";
                        
    $headers2 .= "--$boundary\r\n";
                        
    $headers2 .= "Content-Type: application/pdf; name="'"Check-in_Instructions.pdf"' "\r\n";
                        
    $headers2 .= "Content-Transfer-Encoding: base64\r\n";
                        
    $headers2 .= "Content-Disposition: attachment; filename="'"Check-in_Instructions.pdf"' "\r\n\r\n";
                        
    $headers2 .= <<<EOT
                    $encoded_data
    EOT;
                        
    $headers2 .= "\r\n\r\rn";
                        
    $headers2 .= "--$boundary\r\n";
                    
                            
    $headers2 .= "Content-Type: application/pdf; name="'"Invoice-'.$bid.'.pdf"' "\r\n";
                            
    $headers2 .= "Content-Transfer-Encoding: base64\r\n";
                            
    $headers2 .= "Content-Disposition: attachment; filename="'"Invoice-'.$bid.'.pdf"' "\r\n\r\n";
                            
    $headers2 .= <<<EOT
                        $invoice_data
    EOT;
                            
    $headers2 .= "\r\n\r\rn";
                            
    $headers2 .= "--$boundary\r\n";
                            

                            
    $success mail($email,"[ref:$bid] Your upcoming stay in $pname -- Info for Arrival & Checkin",$headers2,$headers); 

  • #2
    Senior Coder NancyJ's Avatar
    Join Date
    Feb 2005
    Location
    Bradford, UK
    Posts
    3,172
    Thanks
    19
    Thanked 65 Times in 64 Posts
    I found the issue - I copy and pasted another developers code (the guy that used to work on the site) and he obviously had fat fingers

    PHP Code:
     $headers2 .= "\r\n\r\rn"
    should be
    PHP Code:
     $headers2 .= "\r\n\r\n"


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •