SMTP through O365 fails

Re: SMTP through O365 fails

by Ken Task -
Number of replies: 2
Picture of Particularly helpful Moodlers

In looking again at original posting ... user id 2 is the user that initially installed the moodle ... like admin ... what email address do you have for that user?

I have found best to use the moodle servers FQDN for that address.

Example: moodle server FQDN is elearning.somenet.net ... for the admin user I would use admin@elearning.somenet.net

That admin user might actually have an account on that server but it's never used to accept mail ... just send.

That would be one of the many items checked by spam checkers.

The other thing I do ... setup either postfix or sendmail as a sending only server.   All mail leaving the moodle then goes through postfix or sendmail ... whose apps keeps logs on the moodle server itself.   Postfix or Sendmail (just the sending part) could be set up with a 'smarthost' config - which basically is any mail not bound to root or local accounts on the moodle server, goes to 'smarthost' for relay/sorting.

I get to see bounces in logs of postfix or sendmail.

The SMTP host ... the true relay to all other email addresses, I more than likely do NOT have full control over ... your o365 ... my Google ... only logins/password/ports and transport can I set in Moodle or Postfix/Sendmail.

I see Bluehost docs say port 26 ... not 25 .. amazing what one digit off will do ... not do! smile

Begin soap box ...

And a comment about hosting ... is it better the 'devils' you know, than the 'devils' you don't?

Hosting providers are not known to have *fully disclosing* capabilities ... and many have a lot of promises ... good marketing ... but technically have difficulty delivering.

Even VPS's limit the customer ... and the general thought on VPS's is account holder can do all things ... well, guess what, not 100% true when it comes to DB (devils you don't know).   When it becomes a contest for control, I'd rather have superuser creds for DB and have to put up with annoyance in EMail.   But that's me ... we all choose our own poisons ... and then learn our own antidotes!

--- end soap box!

'SoS', Ken



In reply to Ken Task

Re: SMTP through O365 fails

by Nate Swetland -
Greatly appreciate all the help so far.

I believe I have made it past the SMTP connection/authentication error but I am running into some Send-As errors it seems. I wound up migrating away from GoDaddy/BlueHost to NameCheap as they are much more responsive and easier to use. They opened port 587 for me without a huge argument like I had with BlueHost...

Anyways...
I feel like I am not fully understanding this no-reply and domain section...

  • My website is set up as a "university.ACME.com" but I dont have any university.acme.com emails and I don't have any desire to.
  • I have a service email account I am using for testing that is "helpdesk@ACME.com"
  • In my no-reply address, I have tried "helpdesk@ACME.com" and no-reply@ACME.com" and blank/default of "no-reply@university.ACME.com"
  • Under Allowed email domains I have tried BLANK/EMPTY, and then I also attempted some combinations of "ACME.com, ACME.onmicrosoft.com, *.ACME.com and university.acme.com"
  • I have tried the "Email via information" as always and never.



when I go to send an email to me@acme.com it fails. It gives me an error about sendasdeniedexception.mapiexceptionsendasdenied

One thing that stands out to me is the line:
2020-01-01 21:08:32    CLIENT -> SERVER: Message-ID: <5e0d0a4de5a8c0.64424587@university.ACME.com>

Why is it trying to use a "university.ACME.com" to send my email?  Can this be corrected?
Why is it using a randomly generated email?    Can this be corrected?

I am starting to see a lot of posts that Send-As through PHP SMTP on Office365 basically doesnt work...

I have an SPF record for both university.ACME.com and ACME.com that include the IP address of my NameCheap shared hosting


Here is the full error message with a little bit of identity scrubbing on it.

2020-01-01 21:08:29    Connection: opening to smtp.office365.com:587, timeout=300, options=array()
2020-01-01 21:08:30    Connection: opened
2020-01-01 21:08:30    SERVER -> CLIENT: 220 BYAPR08CA0028.outlook.office365.com Microsoft ESMTP MAIL Service ready at Wed, 1 Jan 2020 21:08:29 +0000
2020-01-01 21:08:30    CLIENT -> SERVER: EHLO university.ACME.com (changed)
2020-01-01 21:08:30    SERVER -> CLIENT: 250-BYAPR08CA0028.outlook.office365.com Hello [MY.WEB.HOST.IP] (changed)
                                         250-SIZE 157286400
                                         250-PIPELINING
                                         250-DSN
                                         250-ENHANCEDSTATUSCODES
                                         250-STARTTLS
                                         250-8BITMIME
                                         250-BINARYMIME
                                         250-CHUNKING
                                         250 SMTPUTF8
2020-01-01 21:08:30    CLIENT -> SERVER: STARTTLS
2020-01-01 21:08:30    SERVER -> CLIENT: 220 2.0.0 SMTP server ready
2020-01-01 21:08:30    CLIENT -> SERVER: EHLO university.ACME.com (changed)
2020-01-01 21:08:30    SERVER -> CLIENT: 250-BYAPR08CA0028.outlook.office365.com Hello [MY.WEEB.HOST.IP]
                                         250-SIZE 157286400
                                         250-PIPELINING
                                         250-DSN
                                         250-ENHANCEDSTATUSCODES
                                         250-AUTH LOGIN XOAUTH2
                                         250-8BITMIME
                                         250-BINARYMIME
                                         250-CHUNKING
                                         250 SMTPUTF8
2020-01-01 21:08:30    CLIENT -> SERVER: AUTH LOGIN
2020-01-01 21:08:30    SERVER -> CLIENT: 334
2020-01-01 21:08:30    CLIENT -> SERVER:
2020-01-01 21:08:30    SERVER -> CLIENT: 334
2020-01-01 21:08:30    CLIENT -> SERVER:
2020-01-01 21:08:31    SERVER -> CLIENT: 235 2.7.0 Authentication successful
2020-01-01 21:08:31    CLIENT -> SERVER: MAIL FROM:
2020-01-01 21:08:31    SERVER -> CLIENT: 250 2.1.0 Sender OK
2020-01-01 21:08:31    CLIENT -> SERVER: RCPT TO:
2020-01-01 21:08:31    SERVER -> CLIENT: 250 2.1.5 Recipient OK
2020-01-01 21:08:31    CLIENT -> SERVER: DATA
2020-01-01 21:08:32    SERVER -> CLIENT: 354 Start mail input; end with .
2020-01-01 21:08:32    CLIENT -> SERVER: Date: Wed, 1 Jan 2020 16:08:29 -0500
2020-01-01 21:08:32    CLIENT -> SERVER: To: ME@ACME.com (changed)
2020-01-01 21:08:32    CLIENT -> SERVER: From: "System Administrator"
2020-01-01 21:08:32    CLIENT -> SERVER: Reply-To: "System Administrator"
2020-01-01 21:08:32    CLIENT -> SERVER: Subject: ACME University ACME University: test message
2020-01-01 21:08:32    CLIENT -> SERVER: Message-ID: <5e0d0a4de5a8c0.64424587@university.ACME.com>
2020-01-01 21:08:32    CLIENT -> SERVER: X-Mailer: PHPMailer 6.0.7 (https://github.com/PHPMailer/PHPMailer)
2020-01-01 21:08:32    CLIENT -> SERVER: MIME-Version: 1.0
2020-01-01 21:08:32    CLIENT -> SERVER: Content-Type: text/plain; charset=UTF-8
2020-01-01 21:08:32    CLIENT -> SERVER:
2020-01-01 21:08:32    CLIENT -> SERVER:
2020-01-01 21:08:32    CLIENT -> SERVER: This is a test message to confirm that you have successfully configured
2020-01-01 21:08:32    CLIENT -> SERVER: your site's outgoing mail.
2020-01-01 21:08:32    CLIENT -> SERVER:
2020-01-01 21:08:32    CLIENT -> SERVER: .
2020-01-01 21:08:32    SERVER -> CLIENT: 554 5.2.0 STOREDRV.Submission.Exception:SendAsDeniedException.MapiExceptionSendAsDenied; Failed to process message due to a permanent exception with message Cannot submit message. 0.35250:0A000D85, 1.36674:0A000000, 1.61250:00000000, 1.45378:02000000, 1.44866:55210000, 1.36674:0E000000, 1.61250:00000000, 1.45378:5A210000, 1.44866:0A020000, 16.55847:3E100000, 17.43559:0000000004020000000000000000000000000000, 20.52176:140F2A8A0A00101043050000, 20.50032:140F2A8A7A17000000000000, 0.35180:48050000, 255.23226:0A00
2020-01-01 21:08:32    SMTP ERROR: DATA END command failed: 554 5.2.0 STOREDRV.Submission.Exception:SendAsDeniedException.MapiExceptionSendAsDenied; Failed to process message due to a permanent exception with message Cannot submit message. 0.35250:0A000D85, 1.36674:0A000000, 1.61250:00000000, 1.45378:02000000, 1.44866:55210000, 1.36674:0E000000, 1.61250:00000000, 1.45378:5A210000, 1.44866:0A020000, 16.55847:3E100000, 17.43559:0000000004020000000000000000000000000000, 20.52176:140F2A8A0A00101043050000, 20.50032:140F2A8A7A17000000000000, 0.35180:48050000, 255.23226:0A00
2020-01-01 21:08:32    SMTP Error: data not accepted.



In reply to Nate Swetland

Re: SMTP through O365 fails

by Visvanath Ratnaweera -
Picture of Particularly helpful Moodlers Picture of Translators
Hi

You wrote:
> One thing that stands out to me is the line:
> 2020-01-01 21:08:32 CLIENT -> SERVER: Message-ID: <5e0d0a4de5a8c0.64424587@university.ACME.com>
>
> Why is it trying to use a "university.ACME.com" to send my email? Can this be corrected?
> Why is it using a randomly generated email? Can this be corrected?

Although the Message-ID has the format of an e-mail address, it is what its name says, just a (globally) unique identifier. So not the reason for rejecting the e-mail message.

> 2020-01-01 21:08:32 CLIENT -> SERVER: From: "System Administrator"

I guess the this forum editor has purged the e-mail address at the end of the line. I guess it to be one of:
> In my no-reply address, I have tried "helpdesk@ACME.com" and no-reply@ACME.com" and blank/default of "no-reply@university.ACME.com"

That is where the From: "on behalf of" address comes in. (BTW, the defaut no-reply@ has no hyphen.)

> STOREDRV.Submission.Exception:SendAsDeniedException.MapiExceptionSendAsDenied; Failed to process message due to a permanent exception with message Cannot submit message.

The server, in this case smtp.office365.com, refused to send e-mails on behalf of @*ACME.com. I have nothing to do with Microsoft, I assume they expect the sender to have "their" domain. May be others can confirm. Failing that, you can try to configure Thunderbird to send e-mails through this server with any random From address.

Edit: Only after replying I see that there were previous posts. So the answer above may be off the mark.