Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Respect mail.smtp.auth setting #6692

Merged
merged 4 commits into from
Dec 13, 2022
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.unreleased.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ For upgrade instructions, please check the [migration guide](MIGRATIONS.released
- Fixed access of remote datasets using the Amazon S3 protocol [#6679](https://github.com/scalableminds/webknossos/pull/6679)
- Fixed a bug in line measurement that would lead to an infinite loop. [#6689](https://github.com/scalableminds/webknossos/pull/6689)
- Fixed a bug where malformed json files could lead to uncaught exceptions.[#6691](https://github.com/scalableminds/webknossos/pull/6691)
- Respect the config value mail.smtp.auth (used to be ignored, always using true) [#6692](https://github.com/scalableminds/webknossos/pull/6692)

### Removed

Expand Down
1 change: 1 addition & 0 deletions app/Startup.scala
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ class Startup @Inject()(actorSystem: ActorSystem,
conf.Mail.Smtp.host,
conf.Mail.Smtp.port,
conf.Mail.Smtp.tls,
conf.Mail.Smtp.auth,
conf.Mail.Smtp.user,
conf.Mail.Smtp.pass,
)
Expand Down
10 changes: 6 additions & 4 deletions app/oxalis/mail/Mailer.scala
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ case class MailerConfig(
smtpHost: String,
smtpPort: Int,
smtpTls: Boolean,
smtpAuth: Boolean,
smtpUser: String,
smtpPass: String,
)
Expand Down Expand Up @@ -54,7 +55,9 @@ class Mailer(conf: MailerConfig) extends Actor with LazyLogging {
multiPartMail.setHostName(conf.smtpHost)
multiPartMail.setSmtpPort(conf.smtpPort)
multiPartMail.setStartTLSEnabled(conf.smtpTls)
multiPartMail.setAuthenticator(new DefaultAuthenticator(conf.smtpUser, conf.smtpPass))
if (conf.smtpAuth) {
multiPartMail.setAuthenticator(new DefaultAuthenticator(conf.smtpUser, conf.smtpPass))
}
multiPartMail.setDebug(false)
multiPartMail.getMailSession.getProperties.put("mail.smtp.ssl.protocols", "TLSv1.2")

Expand All @@ -69,17 +72,16 @@ class Mailer(conf: MailerConfig) extends Actor with LazyLogging {
/**
* Extracts an email address from the given string and passes to the enclosed method.
*/
private def setAddress(emailAddress: String)(setter: (String, String) => _) {
private def setAddress(emailAddress: String)(setter: (String, String) => _): Unit =
try {
val iAddress = new InternetAddress(emailAddress)
val address = iAddress.getAddress
val name = iAddress.getPersonal

setter(address, name)
} catch {
case _: Exception => ()
case e: Exception => logger.warn(s"Failed to set email address: $e")
}
}

/**
* Creates an appropriate email object based on the content type.
Expand Down
1 change: 0 additions & 1 deletion conf/application.conf
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,6 @@ mail {
pass = ""
}
defaultSender = "webKnossos <[email protected]>"
reply = "webKnossos <[email protected]>"
mailchimp {
host = ""
listId = ""
Expand Down