BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.

Hello community,

 

i try to send an email from a Microsoft Office 365 account from a SAS programm via SMTP over an SMTP relay.

 

Setup: i followed the documentation for "Option 3" (https://docs.microsoft.com/en-us/Exchange/mail-flow-best-practices/how-to-set-up-a-multifunction-dev... ).

The other options will not work for us.

 

All technical aspects of the connection are fullfilled. I can successfully send an email from the SAS server over the gateway via powershell.

 

 

If i try to send the email from SAS code with the same settings i get an error:

ERROR: Login failure
ERROR: Email: 504 5.7.4 Unrecognized authentication type [BE0DEU01FT015.eop-deu01.prod.protection.outlook.com]

 

This is the code i use:

options emailhost=("xxx.mail.protection.outlook.com" 
AUTH=LOGIN STARTTLS PORT=25
PWD="xxx" USERID="xxx@mydomain.com" );

Filename EmailOut Email 
                        From     = "xxx@mydomain.com"
                        To       = "me@someotherdomain.com"
                        Subject  = "test from SAS"
                        debug
;
Data _NULL_;
   File EmailOut;
   Put "test";
Run;

This is the full SMTP communication:

R: 220 FR2DEU01FT017.mail.protection.outlook.com Microsoft ESMTP MAIL Service ready at Fri, 16 Oct 2020 08:52:03 +0000
S: EHLO test.mydomain.com
R: 250-FR2DEU01FT017.mail.protection.outlook.com Hello [13.80.23.30]
R: 250-SIZE 157286400
R: 250-PIPELINING
R: 250-DSN
R: 250-ENHANCEDSTATUSCODES
R: 250-STARTTLS
R: 250-8BITMIME
R: 250-BINARYMIME
R: 250-CHUNKING
R: 250 SMTPUTF8
S: STARTTLS
R: 220 2.0.0 SMTP server ready
S: EHLO test.mydomain.com
R: 250-FR2DEU01FT017.mail.protection.outlook.com Hello [13.80.23.30]
R: 250-SIZE 157286400
R: 250-PIPELINING
R: 250-DSN
R: 250-ENHANCEDSTATUSCODES
R: 250-8BITMIME
R: 250-BINARYMIME
R: 250-CHUNKING
R: 250 SMTPUTF8
S: AUTH LOGIN
R: 504 5.7.4 Unrecognized authentication type [FR2DEU01FT017.eop-deu01.prod.protection.outlook.com]
ERROR: Login failure
ERROR: Email: 504 5.7.4 Unrecognized authentication type [FR2DEU01FT017.eop-deu01.prod.protection.outlook.com]

 

For me it looks like SAS does not correctly implement the SMTP protocol and cannot process the response from the MS Outlook server.

I also tried different SAS emailhost options including the use of SSL instead of STARTTLS. Nothing worked.

 

Has anybody successfully used the Office 365 SMTP gateway or an idea how i can fix the problem?

 

Thank you in advance!

Andreas

1 ACCEPTED SOLUTION

Accepted Solutions
AndreasMenrath
Pyrite | Level 9

Thank you all for the feedback (except the Microsoft rant).

 

In the meantime i set up an local email relay with postfix on the SAS server (if anybody is interested here is a manual:https://www.middlewareinventory.com/blog/postfix-relay-office-365/).

This solution works perfectly when i connect from SAS to localhost:25 and postfix does the heavy lifting.

View solution in original post

6 REPLIES 6
AndreasMenrath
Pyrite | Level 9

here is the code

$cred = Get-Credential

Send-MailMessage -To "me@someotherdomain.com" -Subject "test" -Body "test" -SmtpServer "xxx.mail.protection.outlook.com" -From "xxx@mydomain.com" -Credential $cred -Port 25 -UseSsl
Kurt_Bremser
Super User

So you test a MS server with a MS client. Given the long and deep history of MS doing subtle changes to standards and protocols so only their software works with their environments, I would suspect that this is another case of MS software not fully complying with standards. AKA vendor-lock-in.

After all, it is the server that rejects the authentication type sent by SAS. And I am quite confident that this part of the   FILENAME EMAIL (which is quite old now) has been thoroughly tested with standard-complying servers.

 

Anyway, this is something that SAS TS should look into, so I recommend to open a track with them.

JuanS_OCS
Amethyst | Level 16

Hi @AndreasMenrath ,

 

a couple of little, perhaps silly questions.

 

1- are you sure you need to use port 25 and not 587 or another?

2- did you download the public certificates from the SMTP server and added them to your SAS Private Java Runtime Environment certificate store? Otherwise, I see hard that the SAS JVM client will be able to handshake TLS with the SMTP server.

Kurt_Bremser
Super User

@JuanS_OCS From the responses

S: STARTTLS
R: 220 2.0.0 SMTP server ready
S: EHLO test.mydomain.com
R: 250-FR2DEU01FT017.mail.protection.outlook.com Hello [13.80.23.30]
R: 250-SIZE 157286400
R: 250-PIPELINING
R: 250-DSN
R: 250-ENHANCEDSTATUSCODES
R: 250-8BITMIME
R: 250-BINARYMIME
R: 250-CHUNKING
R: 250 SMTPUTF8

I take it that the STARTTLS worked, and the problem arises later here:

S: AUTH LOGIN
R: 504 5.7.4 Unrecognized authentication type [FR2DEU01FT017.eop-deu01.prod.protection.outlook.com]
AndreasMenrath
Pyrite | Level 9

Thank you all for the feedback (except the Microsoft rant).

 

In the meantime i set up an local email relay with postfix on the SAS server (if anybody is interested here is a manual:https://www.middlewareinventory.com/blog/postfix-relay-office-365/).

This solution works perfectly when i connect from SAS to localhost:25 and postfix does the heavy lifting.

suga badge.PNGThe SAS Users Group for Administrators (SUGA) is open to all SAS administrators and architects who install, update, manage or maintain a SAS deployment. 

Join SUGA 

CLI in SAS Viya

Learn how to install the SAS Viya CLI and a few commands you may find useful in this video by SAS’ Darrell Barton.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 6 replies
  • 8562 views
  • 0 likes
  • 3 in conversation