简体   繁体   中英

\r\n Not Working in text email coding?

I am sending an email which attaches a pdf.

This is the code:

 $mpdf->WriteHTML($html);
 $content = $mpdf->Output('', 'S');
 $content = chunk_split(base64_encode($content));
 $mailto = $email;
 $from_name = $yourname;
 $from_mail = $fromwho;
 $replyto = $replyto;
 $uid = md5(uniqid(time())); 
 $subject = 'Horse Details';
 $message = 'Please find attached details about the horse medical treatment.';
 $filename = 'Horse';
 $header = "From: ".$from_name." <".$from_mail.">\r\n";
 $header .= "Reply-To: ".$replyto."\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/plain; charset=iso-8859-1\r\n";
 $header .= "Content-Transfer-Encoding: 7bit\r\n\r\n";
 $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."--";

I would like to add more details in the message and use \\r\\r for new paragraphs etc.

But for some reason the \\r\\r or \\n will not work? Suspect it is because of some of the header info but not sure which one? Had a bit of a play but could not work it out.

Can you see the problem?

Thank you.

well i don't seem to get it wrong when i sent it , here's the source of the sent message

Subject: Horse Details From: elibyy Reply-To: test@test.org MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="660d0865650c12fa07c8430814690009"

This is a multi-part message in MIME format. --660d0865650c12fa07c8430814690009 Content-type:text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 7bit

Please find attached details about the horse medical treatment.

--660d0865650c12fa07c8430814690009 Content-Type: application/pdf; name="Horse" Content-Transfer-Encoding: base64 Content-Disposition: attachment; filename="Horse"

--660d0865650c12fa07c8430814690009--

Please find attached details about the horse medical treatment.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM