Linode Forum
https://forum.linode.com/

javax.mail.MessagingException: 501
https://forum.linode.com/viewtopic.php?f=11&t=5134
Page 1 of 1

Author:  afrodom [ Sun Jan 31, 2010 8:48 am ]
Post subject:  javax.mail.MessagingException: 501

Hi. I have just installed the Exim MTA on Debian 5. After installation I have tested it by typing in shell :
echo "This is a test." | mail -s Testing someone@somedomain.com
, where someone@somedomain.com is my mail.
And it was successful sending of email, to specified address.
However, when I try to send an email from my application, because my application does that, I try to specify my smtp server as 'localhost' in my code, using java mail, like this :

Code:
   properties = new Properties( );
   properties.put("mail.host", 'localhost');
   session = Session.getInstance(properties, null);


..etc...

When I do so I get an exception :

Code:
javax.mail.MessagingException: 501 Syntactically invalid HELO argument(s)

at com.sun.mail.smtp.SMTPTransport.issueCommand(SMTPTransport.java:1634)
at com.sun.mail.smtp.SMTPTransport.helo(SMTPTransport.java:1070)
at com.sun.mail.smtp.SMTPTransport.protocolConnect(SMTPTransport.java:458)
at javax.mail.Service.connect(Service.java:291)
at javax.mail.Service.connect(Service.java:172)
at javax.mail.Service.connect(Service.java:121)
...more stack here



However, I try to specify mail server as a 'mail.quarksystems.eu', where quarksystems.eu is my domain, I got a following error :

Code:
javax.mail.MessagingException: Could not connect to SMTP host: quarksystems.eu, port: 25;
nested exception is:
java.net.ConnectException: Connection refused
at com.sun.mail.smtp.SMTPTransport.openServer(SMTPTransport.java:1545)
at com.sun.mail.smtp.SMTPTransport.protocolConnect(SMTPTransport.java:453)
at javax.mail.Service.connect(Service.java:291)
at javax.mail.Service.connect(Service.java:172)
at javax.mail.Service.connect(Service.java:121)
...more...



So, how can I find out, what is the name of my server, in order to send a mail, or where to configure it, or do I event need to specify that property?
Thanks in advance

Author:  afrodom [ Sun Jan 31, 2010 10:01 am ]
Post subject: 

It will be my pleasure, to inform (and save further rookies of Linoide hours, and hours -at least I have spent about 10 hours to figure out a problem), about this exception issue, and how to fix it, especially if they are newbies in Linode, as I am.
As you guess, the solution is as stupid as it was expected.
First, you SMTP server, during Session configuration (if u use JavaMail API) is "localhost".
Second, [u]set your hostname to appointing your domain :
example :

echo "rookiedebugger.com" > /etc/hostname
hostname -F /etc/hostname

Reboot your Linode and, finally send an email:)

Author:  kangaby [ Mon Feb 01, 2010 7:20 am ]
Post subject: 

afrodom wrote:
echo "rookiedebugger.com" > /etc/hostname
hostname -F /etc/hostname



Except that /etc/hostname should be the name of your machine, like server, or www, or joeblogs or some other single name:

Now set the hostname of the machine. We'll be calling it "server":

echo server > /etc/hostname
hostname -F /etc/hostname

Then logout and log back in for the new hostname to take effect

Setup the servers host name resolution
Edit /etc/hosts

127.0.0.1 localhost.localdomain localhost
10.10.10.10 server.example.com server

Page 1 of 1 All times are UTC-04:00
Powered by phpBB® Forum Software © phpBB Group
http://www.phpbb.com/