Issue when sending emails in SaaS environnement with 2 smtp (one internal and gmail)

63 views
Skip to first unread message

Nicolas Micoud

unread,
Jul 1, 2020, 6:07:31 AM7/1/20
to iDempiere
Hello,

One of the customer of our SaaS environnement doesn't have a domain name and is using gmail addresses.
Emails sent from our application are sometimes considered as spam when received by their customers.

So I'm trying to adapt setup so their tenant will use smtp.gmail.com whereas other will uses our.
ATM, I'm working on our test instance and I found a blocking issue, which is weird.

From the tenant using smtp.gmail.com, emails are sent (and received ^^), but when switching to another tenant (using 'our' smtp server), emails are not sent.
In other words, once an email has been sent from a smtp.gmail.com, it is not possible to send emails from another server.

Steps to reproduce :

 - Setup System and Client1 with an 'internal' smtp ; check emails are sent (using EMail Test process, is easy)
 - Setup Client2 with an smtp.gmail.com ; check emails are sent
 - Restart the server
 - Log into System and execute EMail Test process : is ok
 - Log into Client1 and execute EMail Test process : is ok
 - Log into Client2 and execute EMail Test process : is ok
 - Log into System or Client1 and execute EMail Test process : is ko
 - Log into Client2 and execute EMail Test process : is ok


I've added some logs in org.compiere.util.EMail.send() in the catch part (AuthenticationFailedException)

When trying to send an email from System (after an email was sent from Client2):
(ME) - Invalid Username/Password - null
(ClientID=0 - auth=null - isGmail=false - isSecureSmtp=false - host=xxx.yyy.zz:0 - from=x...@yyy.fr - subject=Expert Light Demo EMail Test)


Seems when sending an email with SMTP authentication and/or ssl/tls should initiate a variable at server level and this variable is never resetted.

Any idea where to look and/or tests to conduct ?

Thanks,

Nicolas

Nicolas Micoud

unread,
Jul 1, 2020, 12:30:05 PM7/1/20
to iDempiere
Hi,

issue found !

On EMail.send(), the props are taken from System.getProperties(); (line ~ 255)

When Client2 (which is using gmail) send an email, the props are updated (at System level) ; see 12 lines from "if (m_auth != null)"

And when System or Client1 (using internal smtp) try to send emails, they are using same properties, but as the server has

Any idea for fixing this ?

ATM, props are updated only when conditions are true (m_auth != null ; isGmail, m_smtpPort > 0 ;  ....) ; maybe would be better to also remove them in the finally block ?

Does it make sense ?

Other idea ?

Thanks,

Nicolas

Hiep Lq

unread,
Jul 1, 2020, 10:53:45 PM7/1/20
to Mohemmed Bilal Ilyas
maybe change 
Properties props = System.getProperties();
to Properties props = new Properties(System.getProperties());
or just Properties props = new Properties(); (not sure what properties sent mail function need to get from system properties)

so email properties keep clean each time call.

--
You received this message because you are subscribed to the Google Groups "iDempiere" group.
To unsubscribe from this group and stop receiving emails from it, send an email to idempiere+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/idempiere/468ee155-166a-4a2b-872e-e2d29619fda2o%40googlegroups.com.


--
Lê Quý Hiệp
Email: hie...@hasuvimex.vn
Skype: admin.hasuvimex

Company: Thanh Hoa Fishery Import - Export J.s.c  (HasuvimexDL 47
Add: Lot E, Le Mon Industrial Zone, Thanh Hoa, Vietnam

Nicolas Micoud

unread,
Jul 2, 2020, 12:53:54 AM7/2/20
to iDempiere
Hello Hiep,

Properties props = new Properties();

is working in my tests.


Thanks,

Nicolas


Le jeudi 2 juillet 2020 04:53:45 UTC+2, Hiep Lq a écrit :
maybe change 
Properties props = System.getProperties();
to Properties props = new Properties(System.getProperties());
or just Properties props = new Properties(); (not sure what properties sent mail function need to get from system properties)

so email properties keep clean each time call.

To unsubscribe from this group and stop receiving emails from it, send an email to idem...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages