Go Back   CodingForums.com > :: Server side development > PHP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 02-20-2008, 01:47 PM   PM User | #1
NancyJ
Senior Coder

 
NancyJ's Avatar
 
Join Date: Feb 2005
Location: Bradford, UK
Posts: 3,162
Thanks: 19
Thanked 65 Times in 64 Posts
NancyJ will become famous soon enough
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); 
__________________
http://www.hazelryan.co.uk
NancyJ is offline   Reply With Quote
Old 02-20-2008, 02:10 PM   PM User | #2
NancyJ
Senior Coder

 
NancyJ's Avatar
 
Join Date: Feb 2005
Location: Bradford, UK
Posts: 3,162
Thanks: 19
Thanked 65 Times in 64 Posts
NancyJ will become famous soon enough
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"
__________________
http://www.hazelryan.co.uk
NancyJ is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 08:48 PM.


Advertisement
Log in to turn off these ads.