* automatically generate plain mail from html

This commit is contained in:
slawkens1 2017-12-26 22:30:52 +01:00
parent c415cf5ffb
commit 4535687b48
4 changed files with 8 additions and 23 deletions

View File

@ -98,7 +98,7 @@ $config = array(
'mail_address' => 'no-reply@your-server.org', // server e-mail address (from:)
'mail_admin' => 'your-address@your-server.org', // admin email address, where mails from contact form will be sent
'mail_signature' => array( // signature that will be included at the end of every message sent using _mail function
'plain' => ''/*'--\nMy Server,\nhttp://www.myserver.com'*/,
'plain' => ""/*"--\nMy Server,\nhttp://www.myserver.com"*/,
'html' => ''/*'<br/>My Server,\n<a href="http://www.myserver.com">myserver.com</a>'*/
),
'smtp_enabled' => false, // send by smtp or mail function (set false if use mail function)

View File

@ -816,9 +816,9 @@ function _mail($to, $subject, $body, $altBody = '', $add_html_tags = true)
$signature_html = $config['mail_signature']['html'];
if($add_html_tags && isset($body[0]))
$body = '<html><head></head><body>' . $body . '<br/><br/>' . $signature_html . '</body></html>';
$tmp_body = '<html><head></head><body>' . $body . '<br/><br/>' . $signature_html . '</body></html>';
else
$body .= '<br/><br/>' . $signature_html;
$tmp_body .= '<br/><br/>' . $signature_html;
if($config['smtp_enabled'])
{
@ -839,7 +839,7 @@ function _mail($to, $subject, $body, $altBody = '', $add_html_tags = true)
$mailer->FromName = $config['lua']['serverName'];
$mailer->Subject = $subject;
$mailer->AddAddress($to);
$mailer->Body = $body;
$mailer->Body = $tmp_body;
$signature_plain = '';
if(isset($config['mail_signature']['plain']))
@ -847,6 +847,9 @@ function _mail($to, $subject, $body, $altBody = '', $add_html_tags = true)
if(isset($altBody[0]))
$mailer->AltBody = $altBody . $signature_plain;
else { // automatically generate plain html
$mailer->AltBody = strip_tags(preg_replace('/<a(.*)href="([^"]*)"(.*)>/','$2', $body)) . "\n" . $signature_plain;
}
return $mailer->Send();
}

View File

@ -159,19 +159,12 @@ if($save)
$new_account->setCustomField('email_hash', $hash);
$verify_url = getLink('account/confirm_email/' . $hash);
$server_name = $config['lua']['serverName'];
$body_plain = $twig->render('mail.account.verify.plain.html.twig', array(
'account' => $tmp_account,
'verify_url' => $verify_url
));
$body_html = $twig->render('mail.account.verify.html.twig', array(
'account' => $tmp_account,
'verify_url' => generateLink($verify_url, $verify_url, true)
));
if(_mail($email, 'New account on ' . $config['lua']['serverName'], $body_html, $body_plain))
if(_mail($email, 'New account on ' . $config['lua']['serverName'], $body_html))
{
echo $twig->render('account.created.verify.html.twig', array(
'account' => $tmp_account

View File

@ -1,11 +0,0 @@
Hello!
Thank you for registering on {{ config.lua.serverName }}!
Here are the details of your account:
Account {% if constant('USE_ACCOUNT_NAME') %}Name{% else %}Number{% endif %}: {{ account }}
Password: ************ (hidden for security reasons)
To verify your email address please click the link below:
{{ verify_url }}
If you haven't registered on {{ config.lua.serverName }} please ignore this email.