Page 1 of 1

Mail over Office365

PostPosted: Wed Dec 05, 2018 6:04 pm
by rieder
Hi

I try to send email over Office365 smtp server (smtp.office365.com).
Port is 587, I have username and password and set mail.smtp.ssl.enable to true.

Any idea what can go wrong?

I tried setting
mail.smtp.starttls.enable
mail.smtp.ssl.trust
mail.smtp.starttls.required
...

Thanks and regards

Re: Mail over Office365

PostPosted: Wed Dec 05, 2018 6:21 pm
by sean
Hi Birgit

Do you have any information about the error from your server log ?

Re: Mail over Office365

PostPosted: Wed Dec 05, 2018 6:31 pm
by rieder
Hi Sean

With:
Code: Select all
mail.from=<our given username>
mail.smtp.auth=true
mail.smtp.host=smtp.office365.com
mail.smtp.username=<our username>
mail.smtp.password=<our given password>
mail.smtp.port=587
mail.smtp.ssl.enable=true

I get the following error:
Code: Select all
Could not connect to SMTP host: smtp.office365.com, port: 587


If I set
Code: Select all
mail.smtp.ssl.enable=false

I get the following error:
Client was not authenticated to send anonymous mail during MAIL FROM [AM6PR06CA0019.eurprd06.prod.outlook.com]

Here
https://javaee.github.io/javamail/docs/api/com/sun/mail/smtp/package-summary.html
I see so many properties that can be set.

Any idea? SSL/TLS problem?

Thanks and regards

Re: Mail over Office365

PostPosted: Fri Dec 07, 2018 2:36 pm
by rafig
Hi Birgit,
there are some more properties you could try & set
Code: Select all
mail.server.allowUnauthenticatedRMIAccess=true
mail.smtp.auth.plain.disable=false
mail.smtp.starttls.enable=true

One of my client solutions is sending loads of email each day via office365.com

Rafi

Re: Mail over Office365

PostPosted: Fri Dec 07, 2018 3:34 pm
by rieder
Hi Rafi

Thank you very much, so at least I know, the mail plugin works with office365.com.
I did try mail.smtp.starttls.enable but not mail.smtp.auth.plain.disable and mail.server.allowUnauthenticatedRMIAccess.
There are so many combinations!

Thanks again and regards

Re: Mail over Office365

PostPosted: Fri Dec 07, 2018 5:30 pm
by sean
Hi Birgit,

This message is what is returned from the mail server, which are usually vendor specific. Often you need to white-list devices that can relay, etc.

I suggest you have a look at this article where people are having the same issue. You may need to configure your 365 account a bit.

Re: Mail over Office365

PostPosted: Fri Dec 07, 2018 7:08 pm
by rieder
Thank you. I'll check that, too.
I'll also asked, if the parameters for the mail server, we received, are ok.
Thanks all so far and regards

Re: Mail over Office365

PostPosted: Mon Dec 10, 2018 10:59 pm
by rieder
Hi

Still no success. I now have a PowerShell Script, that works. But I cannot configure the mail plugin of Servoy to make it send mail according to the args.
I attach the PS script.

Any help from anybody out there?

Thanks and regards

Re: Mail over Office365

PostPosted: Tue Dec 11, 2018 5:08 pm
by swingman
I'm having the same problem now trying to send mail via smtp.office365.com.
Is the TLS provided by Servoy the old version?

Re: Mail over Office365

PostPosted: Tue Dec 11, 2018 5:25 pm
by swingman
Bingo, I have managed to send using this:

Code: Select all
var properties = new Array();

properties.push('mail.smtp.starttls.enable=true');
properties.push('mail.smtp.ssl.enable=false');         
properties.push('mail.smtp.port=587');
properties.push('mail.smtp.tls.enable=true');
properties.push('mail.smtp.ssl.protocols=TLSv1.2');
properties.push('mail.smtp.host=smtp.office365.com');

var success = plugins.mail.sendMail(to, from, correspondence_subject_text, msg, cc, bcc, attachments,properties);


It was quicker to override the settings while sending, rather than restart the developer after each change on the admin page.

Hope this helps,

The critical bits seems to be TLSv1.2 and setting ssl.enable=false (seems a bit counter-intuitive)

Re: Mail over Office365

PostPosted: Tue Dec 11, 2018 8:02 pm
by rieder
Hi Christian

Wow, I'm looking forward to success! Thank you for the hints with the properties you used!
I'm busy now, trying. I use your properties plus

Code: Select all
mail.smtp.username
mail.smtp.password

I get the error: Could not convert socket to TLS

Code: Select all
mail.smtp.username
mail.smtp.password
mail.smtp.auth=true

I get the error: Could not convert socket to TLS

Code: Select all
mail.smtp.username
mail.smtp.password
mail.smtp.auth=true
mail.smtp.ssl.trust=*

I get the error: Authentication unsuccessful

What other properties do you set? On admin page or in code? Do you set the password in plain text in the code or base64 encoded?

Still searching the total amount of properties. Every hint will be appreciated a lot. Thanks and regards.

Re: Mail over Office365

PostPosted: Tue Dec 11, 2018 8:20 pm
by rieder
Got it!!!

These are the additional properties I did need:

Code: Select all
properties.push('mail.from=<username without @xxx.ch>');
properties.push('mail.smtp.ssl.trust=*');
properties.push('mail.smtp.auth=true');
properties.push('mail.smtp.username=<myname@xxx.ch');   
properties.push('mail.smtp.password=<Plaintext>');


Finally! Thanks to all who helped.

Regards

Re: Mail over Office365

PostPosted: Tue Dec 11, 2018 11:59 pm
by swingman
Great that you succeeded! I set the username and password on the admin page.