phpBeginner06 Posted February 22, 2007 Share Posted February 22, 2007 I wrote a php script to send html email and now I would like to be able to send multi-part/alternative to email clients that can not view/display HTML. I tried to change content type to make this work; but I am not sure how I need to add the binarys to my script. <?php $to="someone@mail.com"; $reply="Reply-To: noresponse@somefakedomain.com"; $from="support@somefakedomain.com"; $subject="About Your Request....."; $message="<center><div style='border:solid 1px #800000;font-family:arial;font-size:20px;width:400px'><img src='somefakeimage.jpg' width='400px' height='100px'></img><br><br>This is a HTML email.<br><br><br><img src='somefakeimage.jpg' width='400px' height='50px'></div></center>"; @mail($to, $subject, $message, "From: $from\n$reply\nContent-Type: multipart/alternative"); ?> Any one know how I can alter my script above to get this to work? Quote Link to comment Share on other sites More sharing options...
redarrow Posted February 22, 2007 Share Posted February 22, 2007 what do you want to do exactly add what? file a doc what? html what? Quote Link to comment Share on other sites More sharing options...
phpBeginner06 Posted February 22, 2007 Author Share Posted February 22, 2007 no - I did not mean binarys - I meant boundries or boundry I want to be able to send both html and text email, for non-html email clients. I do not know how to set boundries so my php email script will send multi-part/alternative as it's content type. Does anyone know how to set the boundries in my script so this will work? Quote Link to comment Share on other sites More sharing options...
redarrow Posted February 22, 2007 Share Posted February 22, 2007 Add the needed headers and send! <?php $headers = "From: \"Me\"<me@here.com>\n"; $headers .= "MIME-Version: 1.0\n"; $headers .= "Content-Type: multipart/mixed; boundary=\"$boundary\""; mail('myAddress@hotmail.com', 'Email with attachment from PHP', $message, $headers); ?> Quote Link to comment Share on other sites More sharing options...
phpBeginner06 Posted February 23, 2007 Author Share Posted February 23, 2007 I tried the code below that "redarrow"; plus added all other needed headers and variables. I am able to send an email to an email address with this code; with all the headers included, but the body of the message does not appear. I have used html in the "$message" variable (email body). So why am I not recieveing a multi-part/alternative email; both in html and/or text? Anyone got any ideas? Here Is My Code <?php $headers = "From: \"Business Name Here\"<support@mydomain.com>\n"; $headers .= "Reply-to: \"Business Name Here\"<noresponse@mydomain.com>\n"; $headers .= "MIME-Version: 1.0\n"; $headers .= "Content-Type: multipart/mixed; boundary=\"$boundary\""; $message = "<div style='color:#00000f'>Hello</div>"; mail('someonesname@aol.com', 'Email Subject Here', $message, $headers); ?> Quote Link to comment Share on other sites More sharing options...
phpBeginner06 Posted February 23, 2007 Author Share Posted February 23, 2007 I found out how to do what I was trying to do. So if any one else would like to find out how to send a multipart/alternative email in PHP (that sends a HTML Version and also a Text Version, for email clients that do not display HTML); visit this page: http://www.webcheatsheet.com/php/send_email_text_html_attachment.php Thanks redarrow for the help. Could not get your script to work and no one else on this forum (at the time I last replied to this thread) knew how to accomplish this; so I found the answer else were. Quote Link to comment 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.