MyBB Community Forums

Full Version: Automated mailsystem css and html styling
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
How can e-mails sent to users in cases of:

-registration
-activation
-lost pw
-new pm
-new reply on subscr...
-....

be styles with css and html?

Only found in several threads the answer on how doing this for mass mail.
and other threads learned me how to change the messages in messages.lang.php
Adding tags and css in above php file will show these tags as plain text in the users their mailbox..
bump.... someone? pls don't tell me nobody struggled with this before
You need to change the content type for the mails to get this displayed not as plain text.
Where is it possible to change that content ?
The content for the mails can be changed in messages.lang.php, the mail type can be changed by define the format, but seams you need to modify this manual, dont see an option or i just miss them.
You can change the default behavior in the definition for the my_mail function.
https://github.com/mybb/mybb/blob/featur...s.php#L541
(2017-05-05, 03:14 PM)broatcast Wrote: [ -> ]The content for the mails can be changed in messages.lang.php, the mail type can be changed by define the format, but seams you need to modify this manual, dont see an option or i just miss them.
You can change the default behavior in the definition for the my_mail function.
https://github.com/mybb/mybb/blob/featur...s.php#L541


thx for you're input broatcast!

I guess it's this peace of code I'll need to change in order to let it mail html formatted emails...

function my_mail($to, $subject, $message, $from="", $charset="", $headers="", $keep_alive=false, $format="text", $message_text="", $return_email="")
{
	global $mybb;
	static $mail;
	// Does our object not exist? Create it
	if(!is_object($mail))
	{
		require_once MYBB_ROOT."inc/class_mailhandler.php";
		if($mybb->settings['mail_handler'] == 'smtp')
		{
			require_once MYBB_ROOT."inc/mailhandlers/smtp.php";
			$mail = new SmtpMail();
		}
		else
		{
			require_once MYBB_ROOT."inc/mailhandlers/php.php";
			$mail = new PhpMail();
		}
	}
	// Using SMTP based mail
	if($mybb->settings['mail_handler'] == 'smtp')
	{
		if($keep_alive == true)
		{
			$mail->keep_alive = true;
		}
	}
	// Using PHP based mail()
	else
	{
		if($mybb->settings['mail_parameters'] != '')
		{
			$mail->additional_parameters = $mybb->settings['mail_parameters'];
		}
	}
	// Build and send
	$mail->build_message($to, $subject, $message, $from, $charset, $headers, $format, $message_text, $return_email);
	return $mail->send();
}
/**
 * Generates a unique code for POST requests to prevent XSS/CSRF attacks
 *
 * @return string The generated code
 */

Which part should I adjust in order to make it work?