move website to windows server from Linux and function has stopped working

Hi

I have a web based system that I have written in php/codeigniter.

It worked fine on a linux server, but I changed hosts to windows server and a bit has stopped working


the system generates a pdf on the fly and attaches it to an email, then sends to a client.  Used to work well... the pdf bit still works (using mpdf)  and they still look good.  But the generation of the email seems to fail... so I am assuming that the way the email is generated is causing problems..

here is some code (simplified and anonymised)

I am passing in the generated pdf ($content) and the name I am giving to the file as $filename, the rest is simple enough...

function send_email($content,$to,$name,$filename, $cc) {
	
		$content = chunk_split(base64_encode($content));
		$mailto = $to;
		$from_name = 'someone';
		$from_mail = 'someone@comecompany.com';
		$replyto = 'someone@comecompany.com';
		$uid = md5(uniqid(time()));
		$subject = 'Some subject';
		
		$header = "From: $from_name <$from_mail>\r\n";
		$header .= "Reply-To: $replyto\r\n";
		$header .= "Cc: $cc\r\n";
		$header	.= "Disposition-Notification-To: $from_mail\r\n"; 
		$header	.= "X-Confirm-Reading-To: $from_mail\r\n"; 
		$header .= "X-Priority: 1 (Highest)\r\n";
        $header .= "X-MSMail-Priority: High\r\n";
        $header .= "Importance: High\r\n";
		$header .= "MIME-Version: 1.0\r\n";
		$header .= "Content-Type: multipart/mixed; boundary=\"".$uid."\"\r\n\r\n";
		$header .= "This is a multi-part message in MIME format.\r\n";
		$header .= "--".$uid."\r\n";
		$header .= "Content-Type: text/html; charset=ISO-8859-1\r\n";
		$header .= "Content-Transfer-Encoding: 7bit\r\n\r\n";

		$message = "Please find attached";
		
		$header .= $message."\r\n\r\n";
		$header .= "--".$uid."\r\n";
		$header .= "Content-Type: application/pdf; name=\"".$filename."\"\r\n";
		$header .= "Content-Transfer-Encoding: base64\r\n";
		$header .= "Content-Disposition: attachment; filename=\"".$filename."\"\r\n\r\n";
		$header .= $content."\r\n\r\n";
		$header .= "--".$uid."--";
		
		
		return @mail($mailto, $subject, "", $header);
	
	
	}

Open in new window



the email does send, and the file is attached, but the email is blank and the attachment wont open, saying the file is corrupt..



any ideas why it wont work on windows hosting?

Cheers

CD
cycledudeAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Dave BaldwinFixer of ProblemsCommented:
It looks to me like it is formatted wrong no matter what hosting.  Your attachment should not be in the header but in the body.  This page http://webcheatsheet.com/PHP/send_email_text_html_attachment.php#attachment shows how to create the MIME boundaries properly.  A different description: http://en.wikipedia.org/wiki/MIME
0
cycledudeAuthor Commented:
well maybe you should enlighten the guys who created mpdf with your findings

http://mpdf1.com/manual/index.php?tid=373
0
Dave BaldwinFixer of ProblemsCommented:
No, I'll settle for just telling you.  The MIME 'standards' were set long before 'mpdf' was written.  Of all of the examples of sending MIME compliant email, the 'mpdf' example is the only one I've seen that puts all that in the headers.

http://us2.php.net/manual/en/function.mail.php
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
cycledudeAuthor Commented:
Thanks, I havent had time to check it out, but lets hope that this can fix my problem
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
PHP

From novice to tech pro — start learning today.