I\'ve been trying for days now to send mail from Grails application and unsuccessfully. I\'m using:
Here's my solution, maybe it's not the best way, but it works for me...
in the mail-config.xml:
${mail.auth}
and here's the setting:
mail.from=XXX Team
mail.host=exchange.xxx.com
mail.port=25
mail.protocol=smtp
mail.auth=false
mail.username=
mail.password=
and finally, the code:
package com.xxx.service;
import org.springframework.mail.javamail.JavaMailSenderImpl;
public class MailSender extends JavaMailSenderImpl {
private boolean authRequired;
@Override
public String getUsername() {
if (!authRequired) {
return null;
}
return super.getUsername();
}
@Override
public String getPassword() {
if (!authRequired) {
return null;
}
return super.getPassword();
}
public boolean isAuthRequired() {
return authRequired;
}
public void setAuthRequired(boolean authRequired) {
this.authRequired = authRequired;
}
}