johnperry / CTP

Clinical Trial Processor
http://mircwiki.rsna.org/index.php?title=CTP_Articles
65 stars 55 forks source link

EmailSender: failure to send mail if SMTP servers do not use authentication #31

Open pjdvolde opened 2 years ago

pjdvolde commented 2 years ago

Hi all,

When using the EmailSender stage in a pipeline at our hospital, when triggered we get the following error message: 09:37:26 INFO [EmailService] EmailService: Unable to establish connection to 192.168.xxx.xxx

Our SMTP server does not use authentication at the moment.

When debugging through adding a trace on the network packets ( netsh trace start capture=yes IPv4.Address=192.168.xxx.xxx) and converting the resulting trace file we get the following result in Wireshark. 535 5.7.0 authentication failed

This leads to believe that somehow authentication is triggered.

On the remark on the configuration tab for EmailService, under 'User name' it is mentioned that "If blank, no authentication is done."

If I follow the code, I get to 'CTP/source/java/org/rsna/ctp/stdstages/email/EmailSender.java' on lines 27-41

public EmailSender(String smtpServer, String smtpPort, String senderUsername, String senderPassword, boolean tls) { this.smtpServer = smtpServer; this.senderUsername = senderUsername; this.senderPassword = senderPassword; Properties props = System.getProperties(); props.put("mail.smtp.host", smtpServer); if (smtpPort != null) props.put("mail.smtp.port", smtpPort); props.put("mail.smtp.starttls.enable", Boolean.toString(tls)); if ((senderUsername != null) && (senderPassword != null)) { props.put("mail.smtp.auth", "true");

Is it possible that both senderUsername and senderPassword are evaluated as string and so will allways be evaluated to be True on line 40?

This would trigger authentication to be used always?

Thanks in advance for looking into it (and for the tool in general of course !) Pieter

johnperry commented 2 years ago

Pieter:

Thanks for catching this problem. I fixed it and put the code and the installer in GitHub.

The installer is also on the RSNA MIRC site at:

http://mirc.rsna.org/download/CTP-installer.jar

I didn't test it because I don't have access to an email server that doesn't require authentication.

Please try it and let me know if it works for you.

JP

From: pjdvolde Sent: Friday, March 18, 2022 5:09 AM To: johnperry/CTP Cc: Subscribed Subject: [johnperry/CTP] EmailSender: failure to send mail if SMTP servers do not use authentication (Issue #31)

Hi all,

When using the EmailSender stage in a pipeline at our hospital, when triggered we get the following error message: 09:37:26 INFO [EmailService] EmailService: Unable to establish connection to 192.168.xxx.xxx

When debugging through adding a trace on the network packets ( netsh trace start capture=yes IPv4.Address=192.168.xxx.xxx) and converting the resulting trace file we get the following result in Wireshark. 535 5.7.0 authentication failed

This leads to believe that somehow authentication is triggered.

On the remark on the configuration tab for EmailService, under 'User name' it is mentioned that "If blank, no authentication is done."

If I follow the code, I get to 'CTP/source/java/org/rsna/ctp/stdstages/email/EmailSender.java' on lines 27-41

` public EmailSender(String smtpServer, String smtpPort, String senderUsername, String senderPassword, boolean tls) { this.smtpServer = smtpServer; this.senderUsername = senderUsername; this.senderPassword = senderPassword;

Properties props = System.getProperties();
props.put("mail.smtp.host", smtpServer);
if (smtpPort != null) props.put("mail.smtp.port", smtpPort);
props.put("mail.smtp.starttls.enable", Boolean.toString(tls));
if ((senderUsername != null) && (senderPassword != null)) {
    props.put("mail.smtp.auth", "true");`

Is it possible that both senderUsername and senderPassword are evaluated as string and so will allways be evaluated to be True on line 40?

This would trigger authentication to be used always?

Thanks in advance for looking into it (and for the tool in general of course !) Pieter

— Reply to this email directly, view it on GitHub, or unsubscribe. Triage notifications on the go with GitHub Mobile for iOS or Android. You are receiving this because you are subscribed to this thread.Message ID: @.***>

pjdvolde commented 2 years ago

Hi John, thanks so much. Works as a charm! Pieter