Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6943177
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T13:07:20+00:00 2026-05-27T13:07:20+00:00

I have a Grails-application that sends emails. The mailserver has no SMTP-authentication, so it

  • 0

I have a Grails-application that sends emails. The mailserver has no SMTP-authentication, so it requires “POP before SMTP”, which means that I need to authenticate against the POP-account before sending through SMTP. Most often it works, but then once in a while, the mailserver is not picked up from the properties, and it tries to connect to “localhost” instead. Here is the properties:

    Properties props = new Properties();

    props.setProperty("mail.store.protocol", "pop3")
    props.setProperty("mail.pop3.host", "mail.xxxxx.com")
    props.setProperty("mail.pop3.port", "110")
    props.setProperty("mail.smtp.host", "mail.xxxxx.com")
    props.setProperty("mail.smtp.port", "25")
    props.setProperty("mail.smtp.sendpartial", "true")
    props.setProperty("mail.pop3.socketFactory.port", "110")
    props.setProperty("mail.pop3.socketFactory.class","javax.net.SocketFactory")
    props.setProperty("mail.pop3.socketFactory.fallback", "false")
    Transport t = null
    def store

    try {
        URLName url = new URLName("pop3", "mail.xxxxxxx.com", 110, 
             "INBOX",  "username", "password");

        Session session = Session.getDefaultInstance(props, null)

        store = session.getStore(url)
        store.connect("mail.xxxxxx.com", "username", "password")

        Message message = new MimeMessage(session);

        message.setFrom(new InternetAddress("xxxx@xxxxxx.com"));

        message.setRecipients(Message.RecipientType.TO, 
            InternetAddress.parse(toAddress, true));

        message.setSubject(mailTitle);
        message.setContent(messageBody, "text/html");
        message.setSentDate(new Date());

        t = session.getTransport("smtp")
        t.connect()
        t.send(message)
        return true
    }
    catch (AddressException e) {
        e.printStackTrace()
        return false
    }
    catch (MessagingException e) {
        e.printStackTrace()
        return false
    }
    finally {
        store?.close()
    }

More often than not, this works. But when a Quartz Job is doing the sending, the mailserver entry from the Properties is not honored and it uses “localhost” instead and then fails to send the emails.

I can connect with Telnet and send with the attributes mentioned.

Could it be a timeout issue? According to what I’ve read in docs, the timeouts are “infinite” as default, so that “should” not be the problem.

Could it be a performance issue? I’ve created a “dummy app”, which – more or less – does the same, but does not issue the sending from a Grails service, but directly from a controller. That one works all the time, but that app is always idleing.

I’m not using the Mail Plugin for Grails, since I couldn’t see that it could handle the “pop before smtp”-paradigm.

Thanks in advance.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T13:07:20+00:00Added an answer on May 27, 2026 at 1:07 pm

    Solution: It looks as though the solution is to put the “mail.smtp.localhost”-value to the same value as for “mail.smtp.host”. Not one single mail has failed since I put that property in. I don’t think it was an obvious property to set and an ignorance from my point of view, nevertheless, I hope this will help someone else in the future.

    So, my properties are as follows:

        Properties props = new Properties();
    
        props.setProperty("mail.store.protocol", "pop3")
        props.setProperty("mail.pop3.host", "mail.xxxxxxx.com")
        props.setProperty("mail.pop3.port", "110")
        props.setProperty("mail.smtp.localhost", "mail.xxxxxxx.com")
        props.setProperty("mail.smtp.host", "mail.xxxxxxx.com")
        props.setProperty("mail.smtp.port", "25")
        props.setProperty("mail.smtp.sendpartial", "true")
        props.setProperty("mail.pop3.socketFactory.port", "110")
        props.setProperty("mail.pop3.socketFactory.class","javax.net.SocketFactory")
        props.setProperty("mail.pop3.socketFactory.fallback", "false")
    

    Setting the value of “mail.smtp.host” to the property “mail.smtp.localhost”, not only made the errors go away, the entire routine became a lot faster.

    Thank you for your efforts!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an existing grails application that uses spring-security plugin for authentication. I would
I have integrated spring security plugin with my grails application, which has hibernate as
I have a grails application that uses spring-security-core and spring-security-ldap, with authentication against Active
I have one grails application.In that I have one model class named Book. From
I have a groovy/grails application that needs to serve images It works fine on
I have developed a grails application that stores a great deal of information. Currently,
Here is the scenario. I have an file outside of my Grails application that
I have grails application on heroku. I use MongoSessionManager which allows, to share session
My Grails application has a large number of enums that look like this: public
I have a Grails application that I am migrating from 1.0.3 to 1.3.7 It

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.