Mail over Office365

Questions and answers on designing your Servoy solutions, database modelling and other 'how do I do this' that don't fit in any of the other categories

Mail over Office365

Postby rieder » Wed Dec 05, 2018 6:04 pm

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
Birgit Rieder
7r AG, Switzerland
SAN Developer
http://www.seven-r.ch
User avatar
rieder
 
Posts: 177
Joined: Thu Jan 26, 2012 5:18 pm

Re: Mail over Office365

Postby sean » Wed Dec 05, 2018 6:21 pm

Hi Birgit

Do you have any information about the error from your server log ?
Software Engineer
Servoy USA
sean
 
Posts: 370
Joined: Mon May 21, 2007 6:26 pm
Location: USA

Re: Mail over Office365

Postby rieder » Wed Dec 05, 2018 6:31 pm

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
Birgit Rieder
7r AG, Switzerland
SAN Developer
http://www.seven-r.ch
User avatar
rieder
 
Posts: 177
Joined: Thu Jan 26, 2012 5:18 pm

Re: Mail over Office365

Postby rafig » Fri Dec 07, 2018 2:36 pm

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
Servoy Certified Developer
Image
rafig
 
Posts: 704
Joined: Mon Dec 22, 2003 12:58 pm
Location: Watford, UK

Re: Mail over Office365

Postby rieder » Fri Dec 07, 2018 3:34 pm

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
Birgit Rieder
7r AG, Switzerland
SAN Developer
http://www.seven-r.ch
User avatar
rieder
 
Posts: 177
Joined: Thu Jan 26, 2012 5:18 pm

Re: Mail over Office365

Postby sean » Fri Dec 07, 2018 5:30 pm

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.
Software Engineer
Servoy USA
sean
 
Posts: 370
Joined: Mon May 21, 2007 6:26 pm
Location: USA

Re: Mail over Office365

Postby rieder » Fri Dec 07, 2018 7:08 pm

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
Birgit Rieder
7r AG, Switzerland
SAN Developer
http://www.seven-r.ch
User avatar
rieder
 
Posts: 177
Joined: Thu Jan 26, 2012 5:18 pm

Re: Mail over Office365

Postby rieder » Mon Dec 10, 2018 10:59 pm

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
Attachments
imagePS.png
imagePS.png (395.53 KiB) Viewed 6762 times
Birgit Rieder
7r AG, Switzerland
SAN Developer
http://www.seven-r.ch
User avatar
rieder
 
Posts: 177
Joined: Thu Jan 26, 2012 5:18 pm

Re: Mail over Office365

Postby swingman » Tue Dec 11, 2018 5:08 pm

I'm having the same problem now trying to send mail via smtp.office365.com.
Is the TLS provided by Servoy the old version?
Christian Batchelor
Certified Servoy Developer
Batchelor Associates Ltd, London, UK
http://www.batchelorassociates.co.uk

http://www.postgresql.org - The world's most advanced open source database.
User avatar
swingman
 
Posts: 1472
Joined: Wed Oct 01, 2003 10:20 am
Location: London

Re: Mail over Office365

Postby swingman » Tue Dec 11, 2018 5:25 pm

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)
Christian Batchelor
Certified Servoy Developer
Batchelor Associates Ltd, London, UK
http://www.batchelorassociates.co.uk

http://www.postgresql.org - The world's most advanced open source database.
User avatar
swingman
 
Posts: 1472
Joined: Wed Oct 01, 2003 10:20 am
Location: London

Re: Mail over Office365

Postby rieder » Tue Dec 11, 2018 8:02 pm

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.
Birgit Rieder
7r AG, Switzerland
SAN Developer
http://www.seven-r.ch
User avatar
rieder
 
Posts: 177
Joined: Thu Jan 26, 2012 5:18 pm

Re: Mail over Office365

Postby rieder » Tue Dec 11, 2018 8:20 pm

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
Birgit Rieder
7r AG, Switzerland
SAN Developer
http://www.seven-r.ch
User avatar
rieder
 
Posts: 177
Joined: Thu Jan 26, 2012 5:18 pm

Re: Mail over Office365

Postby swingman » Tue Dec 11, 2018 11:59 pm

Great that you succeeded! I set the username and password on the admin page.
Christian Batchelor
Certified Servoy Developer
Batchelor Associates Ltd, London, UK
http://www.batchelorassociates.co.uk

http://www.postgresql.org - The world's most advanced open source database.
User avatar
swingman
 
Posts: 1472
Joined: Wed Oct 01, 2003 10:20 am
Location: London


Return to Programming with Servoy

Who is online

Users browsing this forum: No registered users and 8 guests