RSS Feed

Atom Feed

Most recent entries

 

Comments welcome - just register first.

Login [ Register ]



Auto-login on future visits

Forgot your password?

About Xigent

Xigent specializes in developing and deploying interactive communications strategies for organizations that want to harness the power of the web. Because launching a web site is merely the first step, we help our clients build a roadmap for communicating their message to the target audience and meeting their objectives.

Using SMTP for Email in ExpressionEngine

Friday, October 03, 2008    Bookmark and Share

We often use SMTP to handle email in ExpressionEngine, especially if we’re installing on a Windows server. ExpressionEngine supports PHP Mail, Sendmail, and SMTP. We found that using SMTP with a mail server running qMail requires some changes to the ExpressionEngine EEmail class in the file core.email.php. The problem is that the EEmail class creates what is called a bare LF (line feed). Qmail will reject messages with a bare LF, causing a send failure. Confused? It’s ok - the fix is quite easy.

If your ExpressionEngine system messages or private messages (from the Communicate tab) are not being delivered, you need to find out if the mail server is reporting an error. Go under Email Settings in System Preferences and turn on debugging. Then send a test message from the Communicate tab. If you see this message, the problem is a bare LF:

451 See http://pobox.com/~djb/docs/smtplf.html.
Unable to send email using SMTP

The solution: the file core.email.php sets a number of variables (near the top), including $newline and $crlf. By default both are set to “\n”. Both lines are commented with instructions to use either “\n” or “\r\n”. We are simply going to change both lines to “\r\n”:

var $newline		= "\r\n";		
var $crlf			= "\r\n";		

Send another test message, with debugging still on. It should go through.

If you’re using the mailing list module, you should make an additional edit. Around line 315, make sure both instances in this block are “\r\n”, replacing “\r”:

function message($body, $alt = '')
{
	global $FNS;
		
	$body = $FNS->insert_action_ids($body);
	$body = rtrim(str_replace("\r\n", "", $body));
		
	if ($alt != '')
	{
		$alt = $FNS->insert_action_ids($alt);
		$alt = rtrim(str_replace("\r\n", "", $alt));
	}

See this post in the EE forum.

SMTP should work fine with these simple fixes. If you’re using PHP Mail, they are probably not necessary.

Posted by xigentdev on 10/03 at 05:18 PM
CMS & Blogs • (0) CommentsPermalink
Page 1 of 1 pages