MyBB Community Forums

Full Version: E-mail Templates
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hello,

I attempted to edit the language file to include my e-mail template but when I tested it out, it literally sent me an email full of HTML code.

What is the correct procedure for this?
You'd need to do core edits.
Look in functions.php at my_mail:
/**
 * Sends an email using PHP's mail function, formatting it appropriately.
 *
 * @param string Address the email should be addressed to.
 * @param string The subject of the email being sent.
 * @param string The message being sent.
 * @param string The from address of the email, if blank, the board name will be used.
 * @param string The chracter set being used to send this email.
 * @param boolean Do we wish to keep the connection to the mail server alive to send more than one message (SMTP only)
 * @param string The format of the email to be sent (text or html). text is default
 * @param string The text message of the email if being sent in html format, for email clients that don't support html
 * @param string The email address to return to. Defaults to admin return email address.
 */
function my_mail($to, $subject, $message, $from="", $charset="", $headers="", $keep_alive=false, $format="text", $message_text="", $return_email="")

As you can see text messages are default. Then look for example in member.php, you'll notice that all my_mail functions keep the default "text" value for formatting.
Do I just change "text" to "html"?
In the function? Then you'd also need to specify $message_text in every MyBB my_mail call for people without HTML enabled in E-mails, I think, otherwise they'll get blank messages.

If you mean calls only, yes that should work if you provide also $message_text for every call you edit. Not sure though, I'm green at PHP/MyBB coding, so you better wait for someone more experienced.
(2013-05-18, 11:56 PM)Knerba Wrote: [ -> ]Do I just change "text" to "html"?

If you're sure that you're ONLY going to use HTML format for sending out emails, than yes, in functions.php, replace
function my_mail($to, $subject, $message, $from="", $charset="", $headers="", $keep_alive=false, $format="text", $message_text="", $return_email="")

by

function my_mail($to, $subject, $message, $from="", $charset="", $headers="", $keep_alive=false, $format="html", $message_text="", $return_email="")
Thanks for the help guys!