Jeba Prince
Jeba Prince

Reputation: 1671

Getting MailSendException in Grails Mail

I am getting the following error:

ERROR

org.springframework.mail.MailSendException: Failed messages:javax.mail.MessagingException: can't determine local email address; message exceptions (1)     are:
Failed message 1: javax.mail.MessagingException: can't determine local email address

CONFIG

grails.mail.host = "xx.xx.com"
grails.mail.port = 25
grails.mail.from = "[email protected]"
grails.mail.username = "[email protected]"
grails.mail.password = "xxx"
grails.mail.props = ["mail.smtp.auth": "true",
    "mail.smtp.socketFactory.port": "25",
    "mail.smtp.socketFactory.fallback": "false"]

CODE

try {
    sendMail {
      to "${params.emailTo}"
      subject "${params.emailSubject}"
      body "${params.emailMessage}"
    }
  }
  catch (Exception e) {
    println e
  }

Upvotes: 4

Views: 2950

Answers (3)

devpeople
devpeople

Reputation: 21

In your CONFIG section, in the line

grails.mail.from = "[email protected]"

You forgot the word 'default'. The correct is:

grails.mail.default.from="[email protected]"

Upvotes: 2

Jeba Prince
Jeba Prince

Reputation: 1671

SOLUTION* **changed too this and it worked

 sendMail {
 to "${params.emailTo}"
 from "[email protected]"
 subject "${params.emailSubject}"
 body "${params.emailMessage}"
}

Upvotes: 3

MAlex
MAlex

Reputation: 1264

Check the port that you have mentioned in the code. Check if the mail server on your machine is sending data from that port.

Upvotes: 1

Related Questions