Jump to content

[SOLVED] Sending HTML Mail issues


monkeytooth

Recommended Posts

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...

pa_goodmail.gif

 

How it actually looks after sending...

pa_badmail.gif

Link to comment
Share on other sites

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..

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

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!!

Link to comment
Share on other sites

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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.