Search the Community
Showing results for tags 'multipart'.
-
I am trying to send a basic email that is multipart via the mail() function in php. I am not interested in using PHPmail. This should be very light weight. Currently when I send email to gmail, it is sending the html part as plain text so all the tags are showing. Here is my code: //GET VAR INPUT $to = htmlentities($_GET['to']); $friendly_from = htmlentities($_GET['friendly_from']); $email_from = htmlentities($_GET['email_from']); $subject = htmlentities($_GET['subject']); $text = htmlentities($_GET['text']); $html = htmlentities($_GET['html']); //SEND EMAIL # Setup mime boundary $mime_boundary = 'Multipart_Boundary_x' . md5(time()) . 'x'; $headers = "MIME-Version: 1.0\r\n"; $headers .= "Content-Type: multipart/alternative; boundary=\"$mime_boundary\"\r\n"; $headers .= "Content-Transfer-Encoding: 7bit\r\n"; $headers .= "Reply-To: " . $email_from . " \r\n"; # Add in plain text version $body.= "--$mime_boundary\n"; $body.= "Content-Type: text/plain; charset=\"charset=us-ascii\"\n"; $body.= "Content-Transfer-Encoding: 7bit\n\n"; $body.= $text; $body.= "\n\n"; # Add in HTML version $body.= "--$mime_boundary\n"; $body.= "Content-Type: text/html; charset=\"UTF-8\"\n"; $body.= "Content-Transfer-Encoding: 7bit\n\n"; $body.= $html; $body.= "\n\n"; # End email $body.= "--$mime_boundary--\n"; # <-- Notice trailing --, required to close email body for mime's # Finish off headers $headers .= "From: " . $friendly_from . " <" . $email_from . ">\r\n"; $headers .= "X-Sender-IP: " . $_SERVER[SERVER_ADDR] . "\r\n"; $headers .= 'Date: ' . date('n/d/Y g:i A') . "\r\n"; # Mail it out return mail($to, $subject, $body, $headers); Here is what I am receiving. (And yes I can accept html emails).
-
Hey guys, Go easy on me, I'm not a large PHP coder at all however here is the issue I am having. I have acquired a wordpress plugin from a guy to deal with ticketing. From this plugin I am sending out a Mime multipart message with both HTML and plain text code. Here's the thing: If I send this out via gmail's SMTP server the message appears perfectly, however if I send it out via pro.turbo-smtp.com it arrives as an attachment due to the fact that in transit it seems to have lost it's Mime-Version: and Content-type: headers such as displayed below: Date: Fri, 19 Dec 2014 16:02:28 +0000 Return-Path: <REMOVEDADDRESS> To: REMOVEDADDRESS From: Name Here <REMOVEDADDRESS> Reply-To: Subject: Booking Confirmation Message-ID: <edc5de8156becec1bf53e402b25c9b93@REMOVED.co.uk> X-Priority: 3 X-Mailer: PHPMailer 5.2.7 (https://github.com/PHPMailer/PHPMailer/) MIME-Version: Content-Type: Content-Transfer-Encoding: 8bit --Part_A_aaa4586399e49459e0dce4368165275f Hey Mr A Sample, Thank you for booking with us. I am more than positive that this is not a PHP issue due to it appearing fine via google's SMTP server, but I am just wondering if anyone has ever came across such a thing and if anyone can shed any light? If anyone wants the PHP code I'm sure I can supply. Many thanks in advance!, Chris