7

I know that CiviCRM can send e-mail using SMTP and SSL by prefixing ssl:// to the SMTP server name, but my organization uses Office365, which only supports SMTP with TLS. Is there a way to get CiviCRM to work with the Office365 SMTP server (ideally without resorting to Postfix and sendmail)?

4
  • Using SMTP directly to hosted mail products will be tangibly slower while the SMTP transaction blocks the PHP request; having a "real" local MTA which then smarthosts to Office 365 allows CiviCRM to offload messages quicker. You seem to want to avoid "resorting to Postfix" so I haven't posted this as an answer, but it's an option worth considering. Commented Apr 10, 2015 at 10:00
  • @ChrisBurgess - I hadn't thought of using the local MTA to smarthost. a bit off-topic but seems like a best practice in terms of performance :) nice. Commented Apr 16, 2015 at 18:25
  • I'll add that as an answer then :) Commented Apr 16, 2015 at 19:04
  • I've updated the question to remove the explicit prohibition on Postfix and sendmail, especially in light of the SMTP TLS auth bug. Commented Jul 20, 2015 at 4:38

5 Answers 5

7

For performance, avoid remote SMTP entirely.

Using SMTP directly to hosted mail products will be tangibly slower while the SMTP transaction blocks the PHP request; having a "real" local MTA which then smarthosts to Office 365 allows CiviCRM to offload messages quicker (local process/filesystem versus remote network).

Stack Exchange prefers documenting the actual process to external links but in this case I'll do the latter since you have several options, and hey, I'm already not answering your actual request :)

2
  • That wasn't nearly as painful as I was expecting it to be, and it's the first time I've ever seen CiviCRM actually send me an e-mail, so I'm absolutely thrilled right now. Thank you! Commented Jul 20, 2015 at 4:40
  • Glad to hear it Russell! Commented Jul 21, 2015 at 2:40
3

CiviCRM supports TLS connections - and IIRC you just preface with ssl:// (even though it's TLS, not SSL) and select the appropriate port.

However, TLS is currently broken if authentication is required - see https://issues.civicrm.org/jira/browse/CRM-14814 and http://forum.civicrm.org/index.php?topic=21960.0. There seems to be an open PR (https://github.com/civicrm/civicrm-packages/pull/66) - I'm not sure why this wasn't merged, but it's against Civi 4.4, and would probably need to be ported forward.

1

I have used tls://pod51010.outlook.com:465 to connect to an Office365 SMTP server with other software (Forum). Since CiviCRM allows us to specify the port, I would just use tls://pod51010.outlook.com as the SMTP Server Name.

I cannot test with CiviCRM right now as I no longer have an Office 365 account, but I would give that a try first.

1

As Jon G notes, TLS is currently broken. The Forum reference gives patching information, which I've just now successfully applied to CiviCRM 4.6.8, running under WordPress 4.3.1. The broken module is: (your http root)/wordpress/wp-content/plugins/civicrm/civicrm/packages/Net/SMTP.php

Searching the module for the text "// CiviCRM: CRM-8744" get you to the right spot to follow the instructions given by TravelingPharaoh in the forum post, reply 10 (BTW: Thanks to TravelingPharaoh). A reboot, and you are in business.

So this is another confirmation of the need for the fix that is in progress, per CRM-14814.

Thanks, guys.

1

In 2023, the easiest answer is a hook in an extension, e.g.:

// Force STARTTLS
function wisctweaks_civicrm_alterMailer(&$mailer, $driver, $params) {
  $mailer->__set('starttls', true);
}

I'm not saying the other answers don't work - but this was easier than testing everything else.

Note that if you want to use STARTTLS without authentication, you need CiviCRM 5.57+ (earlier versions of the pear/mail and pear/net libraries didn't support it.

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.