monkeytooth Posted April 26, 2008 Share Posted April 26, 2008 Alright im tempting to send an HTML based email via php. Which I have done in the past but not as elaborately as this one.. Below im gonna throw up pictures and code.. Code <?php $to = $_POST['ref_trmail']; $subject = '[Poetry Asylum] - ' . $ptitle; $message = ' <html> <head> <title>[Poetry Asylum] - ' . $ptitle . '</title> </head> <body> <table border=\"0\" width=\"550\" id=\"table1\" cellspacing=\"0\" cellpadding=\"0\" bgcolor=\"#FFFFFF\"> <tr> <td> <img border=\"0\" src=\"pa_mlisthdr.png\" width=\"550\" height=\"131\"></td> </tr> <tr> <td bgcolor=\"#FFFFFF\" align=\"right\"><font face=\"Verdana\" size=\"1\"><b> Links<u>:</u></b> <a target=\"_blank\" href=\"http://www.poetryasylum.com\"> Home</a> | <a href=\"http://www.poetryasylum.com/index.php?a2ml=$ref_trmail\">Join Mailing List</a> | <a href=\"http://www.poetryasylum.com/index.php?bdx=shrpoem\">Post a Poem</a> </font></td> </tr> <tr> <td bgcolor=\"#FFFFFF\"><font face=\"Verdana\" size=\"1\"> </font> <table border=\"0\" width=\"550\" id=\"table59\" cellspacing=\"0\" cellpadding=\"0\"> <tr> <td align=\"center\" valign=\"top\"> <table border=\"0\" width=\"500\" id=\"table60\"> <tr> <td align=\"left\" valign=\"top\" width=\"115\" bgcolor=\"#FFFFCC\"> <font face=\"Verdana\" size=\"1\"><b>From:</b></font></td> <td align=\"left\" valign=\"top\" bgcolor=\"#FFFFCC\"> <font face=\"Verdana\" size=\"1\">' . $_POST['ref_yrname'] . ' / ' . $_POST['ref_yrmail'] . '</font></td> </tr> <tr> <td align=\"left\" valign=\"top\" width=\"115\" bgcolor=\"#FFFFCC\"> <font face=\"Verdana\" size=\"1\"><b>To:</b></font></td> <td align=\"left\" valign=\"top\" bgcolor=\"#FFFFCC\"> <font face=\"Verdana\" size=\"1\">' . $_POST['ref_trname'] . ' / ' . $_POST['ref_trmail'] . '</font></td> </tr> <tr> <td align=\"left\" valign=\"top\" width=\"115\" bgcolor=\"#FFFFCC\"> <font face=\"Verdana\" size=\"1\"><b>Optional Message:</b></font></td> <td align=\"left\" valign=\"top\" bgcolor=\"#FFFFCC\"> <font face=\"Verdana\" size=\"1\">$S1b</font></td> </tr> </table> </td> </tr> </table> <font face=\"Verdana\" size=\"1\"> <br> Poem ID: $id<br> </font><table border=\"0\" width=\"550\" id=\"table55\" cellspacing=\"0\" cellpadding=\"0\"> <tr> <td> <img border=\"0\" src=\"http://www.poetryasylum.com/images/pa_quote_01.png\" width=\"12\" height=\"15\"><b><font size=\"2\" face=\"verdana\" color=\"#000000\">' . $ptitle . '</font></b><img border=\"0\" src=\"file:///D:/Templates/poetryasylum.com_v6_2008/images/pa_quote_03.png\" width=\"12\" height=\"15\"></td> </tr> <tr> <td> <table border=\"0\" width=\"550\" id=\"table56\"> <tr> <td width=\"25\" align=\"left\" valign=\"top\"> <font size=\"1\" face=\"Verdana\"> </font></td> <td align=\"left\" valign=\"top\" width=\"649\"><font size=\"1\"> </font><font size=\"2\"><br> <font size=\"1\" face=\"verdana\" color=\"#000000\">' . $pbody . '</font><br> </font></td> </tr> </table> </td> </tr> <tr> <td> <table border=\"0\" width=\"550\" id=\"table57\"> <tr> <td align=\"left\" width=\"337\" valign=\"top\"> <font size=\"1\" face=\"Verdana\"><b>Author:</b> ' . $pauthor . '</font></td> <td align=\"right\" width=\"337\" valign=\"top\"> <font size=\"1\" face=\"Verdana\"><b> Time/Date:</b> ' . $ptime . ' / ' . $pdate . '</font></td> </tr> </table> </td> </tr> </table> </td> </tr> <tr> <td bgcolor=\"#FFFFFF\"><font face=\"Verdana\" size=\"1\"> </font></td> </tr> <tr> <td align=\"center\" valign=\"bottom\" bgcolor=\"#FFFFFF\"> <font face=\"Verdana\" color=\"#333333\" size=\"1\">© 1999-' . date('Y') . ' </font><font face=\"Verdana\" color=\"#FFFFFF\" size=\"1\"> <a href=\"http://www.poetryasylum.com\"> <font color=\"#333333\">Poetry Asylum</font></a></td> </tr> </table> </body> </html> '; $headers = 'MIME-Version: 1.0' . "\r\n"; $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; $headers .= 'From: Poem Share <poetry@poetryasylum.com>' . "\r\n"; mail($to, $subject, $message, $headers); ?> Now mind you it sends, populates the way it should etc.. but looks nothing like it should.. nor is it being turned off so to speak as some email clients and email ISPs set by defualt, where you have to click Display images/html example: thunderbird, outlook, or gmail and hotmail. How it should look in essence... How it actually looks after sending... Quote Link to comment Share on other sites More sharing options...
monkeytooth Posted April 26, 2008 Author Share Posted April 26, 2008 Soo.. what am I missing, doing wrong.. whatever? anyone.. This is gonna drive me batty.. been reading php.net manual.. scrounging around on google etc for an answer, and I dunno.. Quote Link to comment Share on other sites More sharing options...
BlueSkyIS Posted April 26, 2008 Share Posted April 26, 2008 you have IMGs in your HTML that need to be complete URLs. i.e., change rc=\"pa_mlisthdr.png\" to rc=\"http://www.whateveryourdomainis.com/pa_mlisthdr.png\" Quote Link to comment Share on other sites More sharing options...
monkeytooth Posted April 26, 2008 Author Share Posted April 26, 2008 oh damn missed that, thought I fixed that part.. lemme try this again.. Quote Link to comment Share on other sites More sharing options...
monkeytooth Posted April 26, 2008 Author Share Posted April 26, 2008 nope, unfortunately no dice.. however I did notice something else.. The links are being stripped too.. right now im testing this to a gmail account and a domain account that i use thunderbird with.. Both still giving me the same thing.. email comes in fine, all info is there.. however again the problems with the images loading, and the links not working.. and the color just being completely off still shines through.. I can't figure this out lol.. note, i did fix the issue with the lack of static code for the images.. Quote Link to comment Share on other sites More sharing options...
BlueSkyIS Posted April 26, 2008 Share Posted April 26, 2008 personally, i'd use an html email script that's already written. this is what i use http://www.phpguru.org/static/mime.mail.html Quote Link to comment Share on other sites More sharing options...
monkeytooth Posted April 26, 2008 Author Share Posted April 26, 2008 Alright got the stuff from phpguru.. whats the best way to use my thing above with there class? Quote Link to comment Share on other sites More sharing options...
monkeytooth Posted April 26, 2008 Author Share Posted April 26, 2008 been playin with it for a bit.. not 100% sure how to take there stuff and intergrate it into what I wanna do.. So, that said.. anyone know what I'm doing wrong with my orginal stuff to make it work? Quote Link to comment Share on other sites More sharing options...
monkeytooth Posted April 26, 2008 Author Share Posted April 26, 2008 You know what, don't care really.. I'm more interested in working things on a me level.. hence why I'm going crazy tempting to make this work.. Theres gotta be something that I am obviously missing.. from my orginal post.. I have attempted diffrent headers.. and all else tempting to make this work.. hell I even tried formating an email in Outlook and Thunderbird and using that as the base html file for the mail function.. In the end I know this is obviously possible.. and I know theres someone out there that can help me with what I am doing, unless I figure it out first but I dunno what I am leaving out.. Should have mentioned earlier that I am also using godaddy (PHP 4.x.x) as a host. But I don't think that holds much ground.. Like I said before I have sent html format mails, just not as elaberate as this one.. usually they are simple pages with a table structure to display data.. never til now have I tried to get it with a couple images embeded.. again.. Everything up to the actual HTML elements actually works thus far.. Its just links color format and images that arent loading currently.. Well the current code is: <?php $to = $_POST['ref_trmail']; $subject = '[Poetry Asylum] - ' . $ptitle; $message = ' <!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\"> <html> <head> <title>[Poetry Asylum] - ' . $ptitle . '</title> </head> <body> <table border=\"0\" width=\"550\" id=\"table1\" cellspacing=\"0\" cellpadding=\"0\" bgcolor=\"#FFFFFF\"> <tr> <td> <img border=\"0\" src=\"pa_mlisthdr.png\" width=\"550\" height=\"131\"></td> </tr> <tr> <td bgcolor=\"#FFFFFF\" align=\"right\"><font face=\"Verdana\" size=\"1\"><b> Links<u>:</u></b> <a target=\"_blank\" href=\"http://www.poetryasylum.com\"> Home</a> | <a href=\"http://www.poetryasylum.com/index.php?a2ml=' . $ref_trmail . '\">Join Mailing List</a> | <a href=\"http://www.poetryasylum.com/index.php?bdx=shrpoem\">Post a Poem</a> </font></td> </tr> <tr> <td bgcolor=\"#FFFFFF\"><font face=\"Verdana\" size=\"1\"> </font> <table border=\"0\" width=\"550\" id=\"table59\" cellspacing=\"0\" cellpadding=\"0\"> <tr> <td align=\"center\" valign=\"top\"> <table border=\"0\" width=\"500\" id=\"table60\"> <tr> <td align=\"left\" valign=\"top\" width=\"115\" bgcolor=\"#FFFFCC\"> <font face=\"Verdana\" size=\"1\"><b>From:</b></font></td> <td align=\"left\" valign=\"top\" bgcolor=\"#FFFFCC\"> <font face=\"Verdana\" size=\"1\">' . $_POST['ref_yrname'] . ' / ' . $_POST['ref_yrmail'] . '</font></td> </tr> <tr> <td align=\"left\" valign=\"top\" width=\"115\" bgcolor=\"#FFFFCC\"> <font face=\"Verdana\" size=\"1\"><b>To:</b></font></td> <td align=\"left\" valign=\"top\" bgcolor=\"#FFFFCC\"> <font face=\"Verdana\" size=\"1\">' . $_POST['ref_trname'] . ' / ' . $_POST['ref_trmail'] . '</font></td> </tr> <tr> <td align=\"left\" valign=\"top\" width=\"115\" bgcolor=\"#FFFFCC\"> <font face=\"Verdana\" size=\"1\"><b>Optional Message:</b></font></td> <td align=\"left\" valign=\"top\" bgcolor=\"#FFFFCC\"> <font face=\"Verdana\" size=\"1\">' . $S1b . '</font></td> </tr> </table> </td> </tr> </table> <font face=\"Verdana\" size=\"1\"> <br> Poem ID: ' . $pmid . '<br> </font><table border=\"0\" width=\"550\" id=\"table55\" cellspacing=\"0\" cellpadding=\"0\"> <tr> <td> <img border=\"0\" src=\"http://www.poetryasylum.com/images/pa_quote_01.png\" width=\"12\" height=\"15\"><b><font size=\"2\" face=\"verdana\" color=\"#000000\">' . $ptitle . '</font></b><img border=\"0\" src=\"http://www.poetryasylum.com/images/pa_quote_03.png\" width=\"12\" height=\"15\"></td> </tr> <tr> <td> <table border=\"0\" width=\"550\" id=\"table56\"> <tr> <td width=\"25\" align=\"left\" valign=\"top\"> <font size=\"1\" face=\"Verdana\"> </font></td> <td align=\"left\" valign=\"top\" width=\"649\"><font size=\"1\"> </font><font size=\"2\"><br> <font size=\"1\" face=\"verdana\" color=\"#000000\">' . $pbody . '</font><br> </font></td> </tr> </table> </td> </tr> <tr> <td> <table border=\"0\" width=\"550\" id=\"table57\"> <tr> <td align=\"left\" width=\"337\" valign=\"top\"> <font size=\"1\" face=\"Verdana\"><b>Author:</b> ' . $pauthor . '</font></td> <td align=\"right\" width=\"337\" valign=\"top\"> <font size=\"1\" face=\"Verdana\"><b> Time/Date:</b> ' . $ptime . ' / ' . $pdate . '</font></td> </tr> </table> </td> </tr> </table> </td> </tr> <tr> <td bgcolor=\"#FFFFFF\"><font face=\"Verdana\" size=\"1\"> </font></td> </tr> <tr> <td align=\"center\" valign=\"bottom\" bgcolor=\"#FFFFFF\"> <font face=\"Verdana\" color=\"#333333\" size=\"1\">© 1999-' . date('Y') . ' </font><font face=\"Verdana\" color=\"#FFFFFF\" size=\"1\"> <a href=\"http://www.poetryasylum.com\"> <font color=\"#333333\">Poetry Asylum</font></a></td> </tr> </table> </body> </html> '; $headers = 'MIME-Version: 1.0' . "\r\n"; $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; $headers .= 'Content-type: text/html; charset=us-ascii' . "\r\n"; $headers .= 'From: Poem Share <poetry@poetryasylum.com>' . "\r\n"; $headers .= 'To: ' . $_POST['ref_trname'] . ' <' . $_POST['ref_trmail'] . '>' . "\r\n"; $headers .= 'Reply-To: ' . $_POST['ref_yrname'] . ' <' . $_POST['ref_yrmail'] . '>' . "\r\n"; $headers .= '1\r\nX-MSMail-Priority: High' . "\r\n"; $headers .= 'X-Mailer: Poetry Asylum mailer v1.0' . "\r\n"; mail($to, $subject, $message, $headers); ?> What is it that I am doing wrong? I can't find anything on google, yahoo, live.. on this.. I get alot of links to people that say I should use Outlook to format it and send it, but nothing really refering to using a website to send it out properly.. I'm at my wits end.. One thing I noticed though is that the emails in gmail and thunderbird come through as plain text with RTF formating.. but looking at a couple random HTML based emails I have from walmart and other places those are tagged as HTML looking at there source its no diffrent from mine as far as how its laid out.. So I assume I am missing a header type or something. Just what is the question, what is the key that unlocks the format block between RTF and HTML? Quote Link to comment Share on other sites More sharing options...
BlueSkyIS Posted April 26, 2008 Share Posted April 26, 2008 one thing stands out: you shouldn't escape double-quotes in single-quoted strings. '<A href=\"something.php\">' should be '<A href="something.php">' Quote Link to comment Share on other sites More sharing options...
monkeytooth Posted April 26, 2008 Author Share Posted April 26, 2008 Oh Hot... nice, removing the escapes from the double quotes did the trick! Thank ya.. Would have never thought of that otherwise, and would still be pounding my head on the desk if it wasn't for you.. I always though regardless you had to escape the double quotes when its contained in the <? ?> area... Thanks again!! Quote Link to comment Share on other sites More sharing options...
BlueSkyIS Posted April 26, 2008 Share Posted April 26, 2008 single quotes means 'literal' for instance: $an_array = array("apple","pear","peach"); echo "{$an_array[1]}"; echo "<BR>"; echo '{$an_array[1]}'; [code] output: pear {$an_array[1]} [/code] Quote Link to comment Share on other sites More sharing options...
monkeytooth Posted April 26, 2008 Author Share Posted April 26, 2008 That makes absolute sence, my dilluted thought process of the single vs the double was if your using doubles in a string you need to use singles to outline it with in a var and static string combo.. Don't ask where I came up with that cause I have no idea, however until now it has never effected anything I have done.. but after today after what your last comment was.. that makes more sence then ever with the double vs singles.. thanks again 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.