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.