soldbychris Posted September 27, 2008 Share Posted September 27, 2008 I have a php script that rotates a daily message from my mysql database. How do I include that query information in the body of a email. Here is the script Any assistance would be appreciated. $query = "SELECT `Date`,`Email`,`Par1`,`Par2`,`Par3`,`Par4`,`Par5` FROM `Emailing` WHERE DATE_FORMAT(Date,'%Y-%m-%d') = CURDATE()"; $result = mysql_query($query) or die(mysql_error()); while($row = mysql_fetch_array($result)){ echo "<h1>Real Estate Term of the Day</h1>"; echo "$Date".$row['Date']; echo "<br>"; echo "<br>"; echo "$Par1".$row['Par1']; echo "<br>"; echo "<br>"; echo "$Par2".$row['Par2']; echo "<br>"; echo "<br>"; echo "$Par3".$row['Par3']; echo "<br>"; echo "<br>"; echo "$Par4".$row['Par4']; echo "<br>"; echo "<br>"; echo "$Par5".$row['Par5']; echo "<br>"; echo "<br>"; } $to = "email"; $subject = "Hi!"; $body = "$Par1".$row['Par1']; $headers = "From: email"; if (mail($to, $subject, $body)) { echo("<p>Message successfully sent!</p>"); } else { echo("<p>Message delivery failed...</p>"); } ?> Quote Link to comment Share on other sites More sharing options...
corbin Posted September 28, 2008 Share Posted September 28, 2008 Learn basic PHP! Just assign what ever variables you want to be in the body variable into the body variable. Quote Link to comment Share on other sites More sharing options...
soldbychris Posted September 28, 2008 Author Share Posted September 28, 2008 Thanks I am taking a crash course in figuring it out. I have managed to get everything working but one thing How do you include a hyperlink in the body of the php generated email without it showing as text after receiving the email. Any assistance would be appreciated Quote Link to comment Share on other sites More sharing options...
CroNiX Posted September 29, 2008 Share Posted September 29, 2008 just send it as http://www.thelink.com/ most mail readers will turn it into a link Quote Link to comment Share on other sites More sharing options...
soldbychris Posted September 29, 2008 Author Share Posted September 29, 2008 I guess that is what I have to do. I will have several links in the email and would like to have hyperlinks. Its been hard trying to find something about it. All of my searching only shows up how to add a link to a php email form. Not how to include a link in a email send using php script. Thanks Quote Link to comment Share on other sites More sharing options...
CroNiX Posted September 29, 2008 Share Posted September 29, 2008 As I stated in my above post, the email program will turn things with http:// into a hyperlink, send one to yourself and see. Quote Link to comment Share on other sites More sharing options...
soldbychris Posted September 29, 2008 Author Share Posted September 29, 2008 Sorry I don't think I explained it right. I know it changes to a hyperlink. I want to change the hyperlink text so its not the url that is visible in the email. Thanks Quote Link to comment Share on other sites More sharing options...
CroNiX Posted September 29, 2008 Share Posted September 29, 2008 can only do that by sending html email Quote Link to comment Share on other sites More sharing options...
soldbychris Posted September 29, 2008 Author Share Posted September 29, 2008 There went a lot of wasted time. No wonder I could not find anything on it. Thanks for letting me know I was going in the wrong direction. Quote Link to comment Share on other sites More sharing options...
getmukesh Posted October 1, 2008 Share Posted October 1, 2008 Replace this code in your code, i think, then you got solution while($row = mysql_fetch_array($result)){ $message = "<h1>Real Estate Term of the Day</h1>"; $message .= "<br>Date".$row['Date']; $message .= "<br>Par1".$row['Par1']; $message .= "<br>Par2".$row['Par2']; $message .= "<br>Par3".$row['Par3']; $message .= "<br>Par4".$row['Par4']; $message .= "<br>Par5".$row['Par5']; } $to = "email"; $subject = "Hi!"; $body = $message; Quote Link to comment Share on other sites More sharing options...
BloodyMind Posted October 2, 2008 Share Posted October 2, 2008 mate just send an HTML MIME Email google this: php html mime email tutorial or anything like that u'll find good ones hope that helped 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.