1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

XF 1.1 Email Styling

Discussion in 'XenForo Questions and Support' started by Jeremy P, Oct 10, 2011.

  1. Jeremy P

    Jeremy P Well-Known Member

    Forgive me if this has been asked already (I tried searching) but what's the appropriate way to style the new emails in 1.1?

    Am I correct that all the colors are inline and hardcoded? Is there no easy way to change them other then editing all the values in the template/phrase?

    Thanks.
     
  2. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

    The HTML code for outgoing emails is in the email templates:

    Admin CP -> Development -> Email Templates

    The HTML uses inline styling.

    This area is only accessible in debug mode. And note that while you can edit the email templates in the Admin CP, your changes will be lost the next time you upgrade. The upgrade script always imports the default email templates from this file:

    install/data/email_templates.xml
     
  3. Jeremy P

    Jeremy P Well-Known Member

    I had figured as much. Thanks Jake.
    I hope this improves before 1.1 is gold, styling the new emails is currently not feasible in the least.
     
  4. DSF

    DSF Well-Known Member

    Jake, thanks for this information.

    How can I reduce the posting content, say 30 or 50 Bytes with trailing "..." ?
     
  5. Luke B

    Luke B Active Member

    I for one can't wait to get my hands on the email templates to make some crazy changes.
     
  6. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

    For which email template? You can use template syntax in the email templates so this helper might work for your purposes:

    Code:
    {xen:helper snippet, $MESSAGE, 50, {xen:array 'fromStart=1', 'stripQuote=1'}}
    
     
    DSF likes this.
  7. DSF

    DSF Well-Known Member

    Jake, this works perfect.
    A update reset the master template only. (xF1.1 RC1)
     
  8. Morgain

    Morgain Well-Known Member

    Debug mode please?

    I have done what I can with Phrases - why on earth is only part of it there? These emails are dreadful and I'm getting loads of complaints after only 2 days live! Too wordy, over designed, too much STUFF before you get to the CONTENT. Not like XF usual style.
     
  9. Morgain

    Morgain Well-Known Member

    Any chance of disabling html emails?

    We can edit the plain text ones but html ones are hidden behind the dire warnings of debug mode.
     
  10. Mouth

    Mouth Well-Known Member

    I am wanting to include the receivers username and email adress within MAIL_CONTAINER. I've tried both {$receiver.username} and {$user.username} with no luck. Can anyone please advise what will work?
     
  11. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

    Untested but...

    library/XenForo/Mail.php

    Add the red code:

    Code:
    	public function getPreparedMailHandler($toEmail, $toName = '', array $headers = array(), $fromEmail = '', $fromName = '', $returnPath = '')
    	{
    		$contents = $this->prepareMailContents();
    		if (!$contents)
    		{
    			return false;
    		}
    
    		$contents = $this->wrapMailContainer($contents['subject'], $contents['bodyText'], $contents['bodyHtml'], $toEmail, $toName);
    
    		$mailObj = new Zend_Mail('utf-8');
    		$mailObj->setSubject($contents['subject'])
    			->setBodyText($contents['bodyText'])
    			->addTo($toEmail, $toName);
    
    		if ($contents['bodyHtml'] !== '')
    		{
    			$mailObj->setBodyHtml($contents['bodyHtml']);
    		}
    
    		$options = XenForo_Application::get('options');
    		if (!$fromName)
    		{
    			$fromName = ($options->emailSenderName ? $options->emailSenderName : $options->boardTitle);
    		}
    
    		if ($fromEmail)
    		{
    			$mailObj->setFrom($fromEmail, $fromName);
    		}
    		else
    		{
    			$mailObj->setFrom($options->defaultEmailAddress, $fromName);
    		}
    
    		if ($returnPath)
    		{
    			$mailObj->setReturnPath($returnPath);
    		}
    		else
    		{
    			$bounceEmailAddress = $options->bounceEmailAddress;
    			if (!$bounceEmailAddress)
    			{
    				$bounceEmailAddress = $options->defaultEmailAddress;
    			}
    			$mailObj->setReturnPath($bounceEmailAddress);
    		}
    
    		foreach ($headers AS $headerName => $headerValue)
    		{
    			if (isset(self::$_headerMap[strtolower($headerName)])) {
    				$func = self::$_headerMap[strtolower($headerName)];
    				$mailObj->$func($headerValue);
    			}
    			else
    			{
    				$mailObj->addHeader($headerName, $headerValue);
    			}
    		}
    
    		return $mailObj;
    	}
    
    Code:
    	public function wrapMailContainer($subject, $bodyText, $bodyHtml, $toEmail, $toName = '')
    	{
    		$contents = $this->prepareMailContents('MAIL_CONTAINER', array(
    			'subject' => $subject,
    			'bodyText' => $bodyText,
    			'bodyHtml' => $bodyHtml,
    			'toEmail' => $toEmail,
    			'toName' => $toName
    		));
    
    		if ($contents)
    		{
    			// remove the bodyHtml so we skip an HTML email if there's nothing
    			if ($bodyHtml === '')
    			{
    				$contents['bodyHtml'] = '';
    			}
    
    			return $contents;
    		}
    		else
    		{
    			return array(
    				'subject' => $subject,
    				'bodyText' => $bodyText,
    				'bodyHtml' => $bodyHtml
    			);
    		}
    	}
    
    That should enable you to use {$toEmail} and {$toName} in the MAIL_CONTAINER template.
     
  12. Mouth

    Mouth Well-Known Member

    Brilliant. Worked perfectly, thanks.

    Has enabled me to put
    PHP:
                <p style="font-size: 9px;">
                
    This email was sent to <a href="{$xenOptions.boardUrl}/account/" title="User {$toName} on Netrider">{$toName}</a> &lt;{$toEmail}&gt;, a registered member of the <b>Netrider community</b>.<br />
                <
    a href="{$xenOptions.boardUrl}/account/contact-details" title="Edit your messaging preferences">Edit Your Messaging Preferences</a>
                </
    p>
    in the bottom of my MAIL_CONTAINER to ensure I meet spam regulations on all emails sent.
     
    CarlosMST and Jake Bunce like this.
  13. Kerby

    Kerby Active Member

    Where can I edit the "BoardTitle" inside a HTML E-Mail Text? It has to be different from ACP>Options>Preferences>Board Title setting. Here you can see the text in the red circle on screenshot:

    2014-10-13_042627.png

    I've tried it with debug mode and developer e-mail template modifications but it seems my TM doesn't work. I've tested it with template "conversation_reply" and "conversation_reply_messagetext". But nothing changed.

    My Template Modifications settings are:
    - Content as HTML
    - simple replacement

    find:
    {$xenOptions.boardTitle}

    replace:
    Domain.ch Best Domains


    It doesn't work. It's still "Xenforo Community" there instead of "Domain.com Best Domains".

    Probably something in library/XenForo/Mail.php? Where can I edit this phrase?
     
  14. Brogan

    Brogan XenForo Moderator Staff Member

    What do you have set in Options -> Basic Board Information -> Board Title ?
     
  15. Kerby

    Kerby Active Member

    I don't want to change globally Board Title. I only want to change the phrase in the e-mail templates. It has to be different from the board title.
     
  16. Rizwan Kassim

    Rizwan Kassim Member

    Any intention to make this easier? I want to remove messagetext from all outgoing messages; users have expressed an interest in not having their forum chats in their email.
     
  17. Jeremy P

    Jeremy P Well-Known Member

    That doesn't really have anything to do with this thread, but it is already available in the core software.

    Options -> Email Options:
    [​IMG]

    Hard to make it much easier really.
     

Share This Page