I have a field that is designated as a RICH(HTML)AREA and it is being used in a email hook. Is it possible to to send it as a HTML field so it displays properly? Anything help would be appreciated.
Thanks,
Michael
Is There a way to display content in HTML
-
- AppGini Super Hero
- Posts: 56
- Joined: 2013-01-10 16:37
- Location: England
- Contact:
Re: Is There a way to display content in HTML
Hi,
Indeed there is! Unfortunately due to school and exams and whatnot I cannot provide a custom hook script but I have made this myself. It's a tad complex but serves a purpose. If you need help understanding it, there's a good tutorial on this here: http://css-tricks.com/sending-nice-html-email-with-php/
My hook is here if you would like to borrow and change it. You will need to adapt it for your table and emails etc:
Hope this helps,
Stephen
Indeed there is! Unfortunately due to school and exams and whatnot I cannot provide a custom hook script but I have made this myself. It's a tad complex but serves a purpose. If you need help understanding it, there's a good tutorial on this here: http://css-tricks.com/sending-nice-html-email-with-php/
My hook is here if you would like to borrow and change it. You will need to adapt it for your table and emails etc:
Code: Select all
function drt_after_insert($data, $memberInfo, &$args){
// Assign the fields of information to a var called messagedata2
// Create a HTML Table
// Strip_Tags to remove HTML from data before emailing
$messageData2 = '<table rules="all" style="border-color: #666;" cellpadding="10">';
$messageData2 .= '<tr><td><b>Name: </b></td><td>';
$messageData2 .= strip_tags ($data['name']) . " </td></tr>";
$messageData2 .= '<tr><td><b>Timestamp: </b></td><td>';
$messageData2 .= strip_tags ($data['time']) . " </td></tr>";
$messageData2 .= '<tr><td><b>Information: </b></td><td>';
$messageData2 .= strip_tags ($data['info']) . " </td></tr>";
$messageData2 .= "<tr><td><b>Update URL: </b></td><td>";
$messageData2 .= strip_tags ($data['source']) . " </td></tr>";
$messageData2 .= "<tr><td><b>System Driver? </b></td><td>";
$messageData2 .= strip_tags ($data['ms']) . " </td></tr>";
$messageData2 .= "</table>";
// To address
$to = '[color=#FF0000]**REMOVED FOR PRIVACY - ENTER AN EMAIL TO SEND MAIL TO**[/color]';
// Subject
$subject = "DRT - New driver added to the DRT";
// Create the message and assign the var $message
$message = "<html><body>";
$message .= '<h1 style = "font: 22px Verdana,Arial,Tahoma,Calibri,Geneva,sans-serif; font-weight:bold; color:#000080;">A New Driver Has Been Added to the DRT.</h1><br />';
$message .= "A driver with the following information was added to the DRT by <strong><a href=geoip.flagfox.net/?ip={$memberInfo['IP']}>{$memberInfo['IP']}</a></strong><br /><br />";
$message .= $messageData2;
$message .= '<br /><br /> To view the driver that has been added, please visit: http://bsodforums.com/drt2/drt_view.php?SelectedID=' . $data['selectedID'];
$message .= '</body></html>';
// From address
$from = "[color=#FF0000]**REMOVED FOR PRIVACY - ENTER AN EMAIL FOR YOUR DOMAIN - I.E. [email protected]**[/color]";
// Name of from sender
$from_name = "Driver Reference Table";
// Create HTML mail
$headers = "From: " . $from_name . "<" . $from . ">" . "\r\n";
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";
//Send mail
mail($to,$subject,$message,$headers);
return TRUE;
}
Stephen
Re: Is There a way to display content in HTML
Thank you for your help, I will try this out..
Michael
Michael
Re: Is There a way to display content in HTML
I am pulling some of the fields from various tables so I need to use $row in place of the $data. Can that be used in the example above interchangeability with $data, or does it require an other syntax. Any help would Be greatly appreciated, as I am closing in on completing my latest application and I am having a issue with the message not displaying correctly.
Thanks,
Michael
Thanks,
Michael
Re: Is There a way to display content in HTML
Ok, I have pretty much figured out how to bring in fields from other tables. Not quite perfect, but usable. However I was wondering if anyone knows how to send the HTML formating along with the email, with out stripping it out? I would love to be able to send formatted HTML messages.
Thanks,
Michael
Thanks,
Michael