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

  • Home
  • SEARCH
  • 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 210041
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T17:58:11+00:00 2026-05-11T17:58:11+00:00

I have some problems sending mails through SMTP using Spring’s MailSender interface and the

  • 0

I have some problems sending mails through SMTP using Spring’s MailSender interface and the concrete implementation JavaMailSenderImpl. I’m able to send mail through GMail, but not through our company SMTP-server (Postfix).

Correct configurations

To see that I have the correct configuration I used the excellent mail sender ssmtp. It’s a simple utility (which is able to emulate Sendmail) and is used solely for sending mail through SMTP.

Below are the two commands I used to send mail. The first one is for GMail and the second one for our company SMTP-server. Both mails arrived as they should and thus the configuration files that follow are correct.

$ ssmtp -C gmail-smtp.conf john.doe@gmail.com < gmail-message.txt 
$ ssmtp -C other-smtp.conf john.doe@thecompany.net < other-message.txt

The contents of the ssmtp configuration files and the message files are listed below. How the configuration file is structured can be seen at: http://linux.die.net/man/5/ssmtp.conf:

gmail-message.txt:

To: john.doe@gmail.com
From: john.doe@gmail.com
Subject: Sent using the SMTP-server of GMail

Some content.

gmail-smtp.conf:

mailhub=smtp.gmail.com:587
UseSTARTTLS=yes
AuthUser=john.doe@gmail.com
AuthPass=john_password

other-message.txt:

To: john.doe@thecompany.net
From: john.doe@thecompany.net
Subject: Sent using the SMTP-server of TheCompany

Some content.

other-smtp.conf:

# No username or password = no authentication
hostname=thecompany.net
mailhub=mail.thecompany.net:25

MailSender configuration which works against GMail

I’m sucessful in sending mail through GMail using this Spring MailSender configuration:

...
<bean id="mailSender" class ="org.springframework.mail.javamail.JavaMailSenderImpl" >
    <property name="host" value="smtp.gmail.com" />
    <property name="port" value="587" />
    <property name="username" value="john.doe@gmail.com" />
    <property name="password" value="john_password" />
    <property name="javaMailProperties">
    <props>
        <prop key="mail.smtp.starttls.enable">true</prop>
    </props>
    </property>
</bean>
...

The problem (sending through the company SMTP-server)

With this MailSender configuration:

...
<bean id="mailSender" class ="org.springframework.mail.javamail.JavaMailSenderImpl" >
    <property name="host" value="mail.thecompany.net" />
    <property name="port" value="25" />
</bean>
...

I get this exception:

org.springframework.mail.MailSendException; nested exceptions (1) are:
Failed message 1: javax.mail.SendFailedException: Invalid Addresses;
nested exception is:
com.sun.mail.smtp.SMTPAddressFailedException: 504 5.5.2 <rat>: Helo command rejected: need fully-qualified hostname

at org.springframework.mail.javamail.JavaMailSenderImpl.doSend(JavaMailSenderImpl.java:422)
at org.springframework.mail.javamail.JavaMailSenderImpl.send(JavaMailSenderImpl.java:308)
at org.springframework.mail.javamail.JavaMailSenderImpl.send(JavaMailSenderImpl.java:297)
... (The rest are methods I've created, which are irrelevant)    

I also get 504 5.5.2 : Helo command rejected: need fully-qualified hostname if I remove hostname=thecompany.net from other-smtp.conf using ssmtp. I guess I have to provide the hostname somehow. My computers name is rat but it seems like it wants thecompany.net.

Any and all help appreciated!

  • 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-11T17:58:11+00:00Added an answer on May 11, 2026 at 5:58 pm

    Try to add the property “mail.smtp.localhost” with correct value (thecompany.net).

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

Sidebar

Ask A Question

Stats

  • Questions 101k
  • Answers 101k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Try returning the text as JSON. Depending on the jQuery… May 11, 2026 at 8:06 pm
  • Editorial Team
    Editorial Team added an answer Use org.directwebremoting.AjaxFilter The doFilter method of the AjaxFilter is called… May 11, 2026 at 8:06 pm
  • Editorial Team
    Editorial Team added an answer This sort of thing you should just write yourself from… May 11, 2026 at 8:06 pm

Related Questions

Sorry the title is a bit crappy, I couldn't quite word it properly. Edit:
We've been having a problem with a mass mailer component that I wrote for
I'm using HTML emails for a client's newsletter. Not using HTML mails is not
I'm using the javax.mail system, and having problems with Invalid Address exceptions. Here's the
Today I needed to parse some data out from an xlsx file (Office open

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.