Typically I'm able to use PHP Mail on sites I develop but this client has an Exchange Server that requires SMTP over TSL. Since Freeform Pro uses the Email module in EE, my contact form needs to work with SMTP over TSL as well. I should note that PHP Mail works fine, it just won't send an admin notify to anyone with the client's email address domain.

My original attempt at changing the email configuration to SMTP resulted in a string of errors based on this line in the CI email library:

A PHP Error was encountered
Severity: Warning
Message: fsockopen() [function.fsockopen]: unable to connect to xxxxxxxx.xxxxxxx.com:25 (Connection refused)
Filename: libraries/Email.php
Line Number: 1675

After a little poking around I ran across the SMTP port settings in the email.php library and changed it to 587. I also put the following in my config.php file:

/* SMTP mail settings
// $config['protocol'] = "smtp";
$config['smtp_server'] = "xxxxxxxx.xxxxxxx.com";
$config['smtp_username'] = "[email protected]";
$config['smtp_password'] = "xxxxxxxxx";
$config['email_smtp_port'] = "587";
$config['smtp_timeout'] = 5;
$config['smtp_crypto'] = "tls";

$config['protocol'] = "smtp"; is from the email.php library file in CI but it doesn't change the dropdown value in EE which is why it's commented out. $config['email_smtp_port'] = "587"; is specified in the hidden config variables in the EE Docs though CI uses $config['smtp_port'] = "587";. I tried both with no visible changes in the results. I discovered $config['smtp_crypto'] = "tls"; in the EL Forums. Not sure if this works or not because I couldn't find any reference to this config variable anywhere else nor was it in the email.php library file in CI (I actually couldn't find any mention of TLS in the email library actually).

After setting all of this I no longer get the errors but the form page just hangs and won't return the thank you page specified in my freeform tags. The form is submitted to Freeform but no user or admin notification emails are sent out.

Per this EL Forum thread I checked to ensure OpenSSL is enabled; it is, from PHP Info OpenSSL support: enabled. Per this EESE thread I checked to see if sockets were enabled; they were, from PHP info Registered Stream Socket Transports: tcp, udp, unix, udg, ssl, sslv3, sslv2, tls.

Any other suggestions? Thoughts as to why this might not be working?

UPDATE: I've marked @nonprofittech's answer as the correct one because it got me 99% of the way there by using Mandrill. There are a few other services as well that would probably work just as well but I trust MailChimp. If you run across this handy article on EE Insider, there seems to be one setting that is different than what's in the screenshot. Mandrill provides a username so use this an not the API key. One other thing I had to do is add $config['email_smtp_port'] = "587"; to my config file so EE could use port 587 to connect to Mandrill. I'm not sure if it's a MT server configuration thing but I got errors when I didn't add this hidden config variable. Since I'm using Escort I'm not entirely sure all these settings are even relevant but I recommend making your life easier and use this add-on. For Mandrill all you need to do is add your API key and check the box next to the service. You can add multiple services and set them in an order of preference to handle fail overs but I only have a Mandrill account so that's all I setup.

So far so good, so in short, Mandrill account + EE Email configuration settings with Mandrill credentials + hidden config variable for port 587 + Escort add-on worked perfectly. This will be the starting point for any future contact forms I have to submit through an Exchange Server or other SMTP server that doesn't allow PHP Mail or SendMail.

  • OK, I got the form to submit but it's VERY slow and I had to edit the CI email.php library file to make it work. Also, the user and admin notifications aren't being sent. Any ideas why not? Commented Feb 7, 2013 at 21:11

3 Answers 3


I'm going to suggestion bypassing the companies setting all together. This is partially to avoid troubleshooting them (if it's the EE install, you'll run into the same issues with my suggestion), but mostly because I've become a big fan of monitoring transactional email.

We work with nonprofits, but I still agree that the missed opportunity is there. But additionally, there are a number of great services now that allow you track and visualize, your transactional emails. I personally love and use, Mandrill by those monkeys at MailChimp.

If your transactional email volume is under 12,000 per month, the service is free. Though its highly likely, that you have no way of knowing of what your transactional volume is, because most people don't measure it. It's just a black hole.

Make Notification, Confirmations, and other Transaction Useful

Mandrill Transaction Overview

The above image is just an overview transaction graph from Mandrill. What transaction email is, really kicked in for me, when someone asked me

Can you tell me how many notification emails EE2 sends and how frequently the bounce?

My response was a big fat, "NO". But then I started making estimates. Turns out, my estimates were way off. I thought around 5,000 transaction per month. That chart above, is a week shy of a full 30 days.

You select any vendor you want, Mandrill, PostMark, Sendgrid, etc. But here's what Mandrill can do for you in your current SMTP situation. You need to figure out:

  1. Is the problem the SMTP send set-up?; or
  2. Is the problem Outlook?

Create an account on Mandrill. This takes maybe 5 minutes. It will provide you with SMPT authentication data. The username will be the company email address you used to start the account and they will provide a secure password. Complete the set-up, then trigger a system email. Setup a new member account, that uses your email address or if your on gmail you could do [email protected].

If the mail sends, you can see it in Mandrill and then hopeful at the same time in your Inbox. That means Outlook configuration was the issue. If you get no love, then its likely that somethings wrong with the SMTP services. The company have ports blocked or some other issue.

The beauty of this as a troubleshooting method is, well you end up with Mandrill configured and tracking all your EE2 generate email. You can see bounces, spam reports, and other issues. Since using it, we've helped clients improve the email messages, focus on reducing registration spam, and more.

At the worse, your client has over 12,000 transactional emails per month and refuses to pay $9.95 per month for up to 40k transactions. You know Outlook is the issue and can focus on that.

  • 2
    Very solid advice. The only thing I will add is that there can be issues with SMTP and hosting providers. Most transactional services recommend using their RESTful API's over the SMTP for this very reason. If you can't get SMTP to work it's worth looking in my Postmaster add-on which allows you to use the Mandrill API directory (bypassing SMTP). Commented Feb 8, 2013 at 15:20
  • I'm going to mark your answer as the correct one with some notes added to my original question for clarification of a few things you might have missed. Commented Mar 13, 2013 at 19:08
  • Justin, I would consider Postmaster if I need the extra mail creation functionality but might I suggest you create a Postmaster lite that just handles the server API connections between EE and the third party transactional email service? Commented Mar 13, 2013 at 19:21
  • Mandrill's great. Plus anything that bypasses Exchange Server is beautiful to me. Sorry, I forgot to mention checking with IT to see if they force traffic to a specific port, though Port 587 is fairly common. Glad it worked. Commented Mar 13, 2013 at 19:39

These posts gave me the hints I needed.

For others it seems they may have to change email_newline and email_crlf to "\r\n" in your config/bootstrap.

CodeIgniter has a smtp_crypto config that can be either ssl or tls. I needed tls to work with AmazonSES. The actual config used by EE is email_smtp_crypto (same for port, docs say smtp_port but in the source email_smtp_port is utilized in at least one place).

so to recap here are some relevant settings in one place:

$config['email_debug']      = 'y';    
$config['webmaster_email']  = "[email protected]";
$config['webmaster_name']   = "Site Name";
$config['email_crlf']       = "\r\n"; // default is "\n"
$config['email_newline']    = "\r\n"; // default is "\n"
$config['mail_protocol']    = 'smtp';
$config['smtp_server']      = 'smtp server';
$config['smtp_port']        = '587'; // Not sure if this is used or not, seems legit, too
$config['email_smtp_port']  = '587';    
$config['smtp_username']    = 'smtp username';
$config['smtp_password']    = 'smtp password';
//$config['smtp_crypto']      = 'tls'; // CodeIgniter setting, doesn't seem to be used
$config['email_smtp_crypto']= 'tls';

Two suggestions:

Enable Email Debugging

When this option is enabled, detailed messages will be displayed whenever you send an email using the Communicate page. This information can be useful in helping to track down any problems you may be experiencing. If you are having difficulty sending email you are encouraged to enable this option.

Then sent test messages from the Communicate page to see the debugging details.

Try setting the port to 26 which the ISP may have enabled instead of 25. You can always check settings in Outlook or another email software too to confirm they are working correctly outside EE.

  • I tried the debugging approach but sending emails through the Communicate panel hang as well. The port is set by the client's IT admin so it's 587 for sure. Commented Feb 7, 2013 at 17:36
  • And when trying the settings through Outlook or something similar you are able to send?
    – Anna_MediaGirl
    Commented Feb 7, 2013 at 17:38
  • I'm going to assume that these settings work because this is the company's email server and we get email from them and they receive email from us. Not trying to sound sarcastic by the way. Commented Feb 7, 2013 at 19:26
  • You can never assume that IMO. Mistakes are made every day. I'd personally confirm. Maybe you have bad credentials?
    – Anna_MediaGirl
    Commented Feb 7, 2013 at 20:12
  • Fair point. I was able to add this account to Outlook and send a message to myself, so it looks like the credentials aren't the problem. Commented Feb 7, 2013 at 20:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.