michaellunsford Posted July 15, 2006 Share Posted July 15, 2006 I have taken an actual multipart/alternative email and copied it character for character. The original displays as HTML, but my version comes in blank with a file attachment called "mime-attachment"I've been hacking away at this for months, trying different variations of the email, but nothing seems to be working. I've tried using \r and \r\n for newlines, and I've just given up. I know I'm missing something simple, someone please set me straingt.Thanks!Want to play with it and see what it's doing?http://www.virtual-showcase.net/mail_test.php Quote Link to comment https://forums.phpfreaks.com/topic/14707-trying-to-create-multipartalternative-email/ Share on other sites More sharing options...
tomfmason Posted July 15, 2006 Share Posted July 15, 2006 post what code you have so far Quote Link to comment https://forums.phpfreaks.com/topic/14707-trying-to-create-multipartalternative-email/#findComment-58673 Share on other sites More sharing options...
pixy Posted July 15, 2006 Share Posted July 15, 2006 You can use the function nl2br() to make new lines into the <br /> tag. Quote Link to comment https://forums.phpfreaks.com/topic/14707-trying-to-create-multipartalternative-email/#findComment-58677 Share on other sites More sharing options...
michaellunsford Posted July 15, 2006 Author Share Posted July 15, 2006 [code]<?phpif ($_POST['subject']) { $recep = explode(",",$_POST['to']); reset($recep); $err=""; $whodat="From: ".$_POST['from']."\n"; $whodat.="MIME-Version: 1.0\n"; $boundary=uniqid("HTMLDEMO"); $whodat.="Content-Type: multipart/alternative;\n\tboundary=\"$boundary\"\n"; $bodytext.="This is a MIME encoded message.\n\n"; $bodytext.="--$boundary\nContent-Type: text/plain; charset=ISO-8859-1\nContent-Transfer-Encoding: 8bit\n\n"; $bodytext.=stripslashes($_POST['plaintext'])."\n"; $bodytext.="--$boundary\nContent-Type: text/html; charset=ISO-8859-1\nContent-Transfer-Encoding: 8bit\n\n"; $bodytext.=stripslashes($_POST['htmltext']); do { if(!mail(current($recep), $_POST['subject'], $bodytext, $whodat)) $err.=current($recep).", "; } while (next($recep)); if($err!="") { echo "Errors! These folks received squat: ".$err; } else echo "Bubba says, \"Check your e-mail!\"";} else echo "<html><head><title>Really Cool Mass Mailer</title><meta http-equiv=\"Content-Type\" content=\"text/html; charset=iso-8859-1\"></head><body><form action=\"mailme.php\" method=\"post\"> <table><tr><td>To:<td><input type=\"text\" name=\"to\"> <tr><td>From:<td><input type=\"text\" name=\"from\"> <tr><td>Subject:<td><input type=\"text\" name=\"subject\"> <tr><td>HTML Message<td><textarea name=\"htmltext\" rows=\"10\" cols=\"80\"></textarea> <tr><td>Plain Text<td><textarea name=\"plaintext\" rows=\"10\" cols=\"80\"></textarea> <tr><td colspan=\"2\"><input type=\"reset\"> <input type=\"submit\"></table></form> </body></html>";?>[/code] Quote Link to comment https://forums.phpfreaks.com/topic/14707-trying-to-create-multipartalternative-email/#findComment-58678 Share on other sites More sharing options...
pixy Posted July 15, 2006 Share Posted July 15, 2006 So what error are you getting exactly? Is it not sending, wrong formatting...? You need to be more specific. :) Quote Link to comment https://forums.phpfreaks.com/topic/14707-trying-to-create-multipartalternative-email/#findComment-58680 Share on other sites More sharing options...
michaellunsford Posted July 15, 2006 Author Share Posted July 15, 2006 [quote]my version comes in blank with a file attachment called "mime-attachment"[/quote]The email arrives in my inbox with no body, just a file attachment called "mime-attachment" Quote Link to comment https://forums.phpfreaks.com/topic/14707-trying-to-create-multipartalternative-email/#findComment-58686 Share on other sites More sharing options...
tomfmason Posted July 15, 2006 Share Posted July 15, 2006 I use the code below and I am able to send both plain text and html .[code=php:0]$headers = "From: you@yoursite.com\r\n" . 'X-Mailer: PHP/' . phpversion() . "\r\n" . "MIME-Version: 1.0\r\n" . "Content-Type: text/html; charset=utf-8\r\n" . "Content-Transfer-Encoding: 8bit\r\n\r\n"; mail($to, $subject, $message, $headers)or die('something went wrong'); [/code]try this instead and see that happensHope this helpsTom Quote Link to comment https://forums.phpfreaks.com/topic/14707-trying-to-create-multipartalternative-email/#findComment-58688 Share on other sites More sharing options...
michaellunsford Posted July 16, 2006 Author Share Posted July 16, 2006 I have been able to get the html only email working, just not the multipart. I'm missing something and just can't figure out what it is.I tried emailing an address I check with my email client and get the blank body with a "mime attachment." If I send it to my old yahoo account, it comes across as plain text -- everything below the header prints just like it's part of an email. It's just nuts. Quote Link to comment https://forums.phpfreaks.com/topic/14707-trying-to-create-multipartalternative-email/#findComment-58961 Share on other sites More sharing options...
michaellunsford Posted July 16, 2006 Author Share Posted July 16, 2006 One other note... the HTML email seems to work with anything but .mac accounts. Any idea what could be causing .mac to not receive the email at all? Quote Link to comment https://forums.phpfreaks.com/topic/14707-trying-to-create-multipartalternative-email/#findComment-59065 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.