Office 365 SMTP

Hi there,

Been using Phabricator for like 2 years now.

I need to setup email relay through office 365. But i keep getting SMTP error so i guess i must have setup the jason file wrong somehow.

This is my mailers.json file:

[
  {
    "key": "Office365SMTP",
    "type": "smtp",
    "options":    {
        "host": "smtp.office365.com",
         "port": 587,
         "user": "phabricator@XXXX-CCCC.dk",
         "password": "DDDDDD",
         "message-id": false,
         "protocol" : "tls"
    }
  }
]

when i run this command i get ok

./bin/config set cluster.mailers --stdin < mailers.json

Reading value from stdin...
Set 'cluster.mailers' in local configuration.

but when i do the send test i errors:

./bin/mail send-test --to AA@BB.dk --subject "phab says hullo" < /tmp/test
Reading value from stdin...
Set 'cluster.mailers' in local configuration.
root@AAA:/var/www/html/phabricator/phabricator# ^C
root@AAA:/var/www/html/phabricator/phabricator# ./bin/mail send-test --to AA@BB.dk --subject "phab says hullo" < /tmp/test
Reading message body from stdin...
[2019-07-23 13:53:57] EXCEPTION: (phpmailerException) SMTP Error: Data not accepted. at [<phabricator>/externals/phpmailer/class.phpmailer.php:741]
arcanist(head=stable, ref.master=b87138356a9c, ref.stable=bbbd1502f078), phabricator(head=stable, ref.master=e0fef74be782, ref.stable=d9b41d3a0f87), phutil(head=stable, ref.master=c3fd3a8bb2c3, ref.stable=0d206344cfd3)
  #0 PHPMailer::SmtpSend(string, string) called at [<phabricator>/externals/phpmailer/class.phpmailer.php:576]
  #1 PHPMailer::Send() called at [<phabricator>/src/applications/metamta/adapter/PhabricatorMailSMTPAdapter.php:155]
  #2 PhabricatorMailSMTPAdapter::sendMessage(PhabricatorMailEmailMessage) called at [<phabricator>/src/applications/metamta/storage/PhabricatorMetaMTAMail.php:750]
  #3 PhabricatorMetaMTAMail::sendWithMailers(array) called at [<phabricator>/src/applications/metamta/storage/PhabricatorMetaMTAMail.php:555]
  #4 PhabricatorMetaMTAMail::sendNow() called at [<phabricator>/src/applications/metamta/PhabricatorMetaMTAWorker.php:22]
  #5 PhabricatorMetaMTAWorker::doWork() called at [<phabricator>/src/infrastructure/daemon/workers/PhabricatorWorker.php:124]
  #6 PhabricatorWorker::executeTask() called at [<phabricator>/src/infrastructure/daemon/workers/PhabricatorWorker.php:163]
  #7 PhabricatorWorker::scheduleTask(string, integer, array) called at [<phabricator>/src/applications/metamta/storage/PhabricatorMetaMTAMail.php:526]
  #8 PhabricatorMetaMTAMail::save() called at [<phabricator>/src/applications/metamta/management/PhabricatorMailManagementSendTestWorkflow.php:228]
  #9 PhabricatorMailManagementSendTestWorkflow::execute(PhutilArgumentParser) called at [<phutil>/src/parser/argument/PhutilArgumentParser.php:457]
  #10 PhutilArgumentParser::parseWorkflowsFull(array) called at [<phutil>/src/parser/argument/PhutilArgumentParser.php:349]
  #11 PhutilArgumentParser::parseWorkflows(array) called at [<phabricator>/scripts/mail/manage_mail.php:21]

I note the error says:

SMTP Error: Data not accepted

which i belive is because there is a error in my SMTP settings.

using powershell i tested if relay was working for the office 365 account and that worked fine. so i don’t think it powershell…

but reading the documentation and post I can’t see where i go wrong with this.

I have firewall turned off on the ubuntu box and on the onprem.

Help me obi van kenobi, you are my only hope!

when i do a:
./bin/mail show-outbound --id 11
I get this:

PROPERTIES
ID: 11
Status: queued
Related PHID:
Message: SMTP Error: Could not connect to SMTP host.

PARAMETERS
sensitive: 1
mustEncrypt:
cc: []
subject: phab says hullo
is-bulk:
mailtags: []
raw-to: [“aa@bb.dk”]
message.type: email

HEADERS

TEXT BODY
test

HTML BODY
(This message has no HTML body.)

I changed the email adress

but it clearly said “SMTP Error: Could not connect to smtp host.”
I can telenet to smtp.office365.com on port 587 with no problem from the server:

root@XXXX:/var/www/html/phabricator/phabricator# telnet smtp.office365.com 587
Trying 40.101.51.194…
Connected to hel-efz.ms-acdc.office.com.
Escape character is ‘^]’.
220 HE1P195CA0013.outlook.office365.com Microsoft ESMTP MAIL Service ready at Wed, 24 Jul 2019 08:31:08 +0000
ehlo mail.XXX.dk
250-HE1P195CA0013.outlook.office365.com Hello [193.221.124.225]
250-SIZE 157286400
250-PIPELINING
250-DSN
250-ENHANCEDSTATUSCODES
250-STARTTLS
250-8BITMIME
250-BINARYMIME
250-CHUNKING
250 SMTPUTF8

i don’t get why this isn’t working…

can i see in a log somewhere some details as to why i can’t connect. How its trying to connect or?

If no one can help would it be possible instead to suggest a mail server software to install on the phabricator server to use instead?

preferably something thats easy to setup and works well with Phabricator?

Any experince welcom :slight_smile:

Am i doing something wrong by posting here? I can’t belive no one can help?

I use Office365 via a postfix relay server on localhost. There are some anti-spam restrictions that Office365 enforces whether you are going direct or via a relay. One of those is that it will not allow a different From address than the logged in account, so Phabricator needs to be configured to send from a single address, which is the one you are logging in as.