Users have reported they don't receive mails. To assist them I need to debug the mails on the test environment. However, mail.debug doesn't produce any output. It works fine on my Dev Environment but I need to do this on the test environment as the e-mail adress in question has IP restrictions on it. My config file is as followed:
grails:
mail:
disabled: "false"
overrideAddress: "xxx"
host: "smtp-relay.gmail.com"
port: 465
username: "xxx"
password: "xxx"
props:
mail.smtp.auth: "true"
mail.smtp.socketFactory.port: "465"
mail.smtp.socketFactory.class: "javax.net.ssl.SSLSocketFactory"
mail.smtp.socketFactory.fallback: "false"
mail.smtp.ssl.enable: "true"
mail.debug: "true"
grails.plugin.springsecurity.ui:
register:
emailFrom: "xxx"
emailSubject: "xxx"
forgotPassword:
emailFrom: "xxx"
emailSubject: "xxx"
Please note that all the entries marked with "xxx" are correctly configured, I just masked them here for security reasons.
It's grails version 3.3.4 deployed on Tomcat 9, Java Version is 8.
I also tried passing
-Dmail.debug=true
and all the log levels are set to DEBUG.
to the Java VM. However, the log produces absolutely nothing regarding mails.
Is there anything I can configure to get some output?
Add logger("grails.plugins.mail", DEBUG)
to your grails-app/conf/logback.groovy
file so it looks something like this at the bottom:
def targetDir = BuildSettings.TARGET_DIR
if (Environment.isDevelopmentMode() && targetDir != null) {
appender("FULL_STACKTRACE", FileAppender) {
file = "${targetDir}/stacktrace.log"
append = true
encoder(PatternLayoutEncoder) {
pattern = "%level %logger - %msg%n"
}
}
logger("StackTrace", ERROR, ['FULL_STACKTRACE'], false)
}
logger("grails.plugins.mail", DEBUG)
root(ERROR, ['STDOUT'])
In Grails 5 and Grails 6 where the logback configuration is stored in an XML file (grails-app/conf/logback.xml
), the same thing can be accomplished by adding <logger name="grails.plugins.mail" level="DEBUG"/>
.