Java Mail Exception - java

I have currently face a problem when I try to send an email using JavaMail API. The exception I get from my application console is :
"javax.mail.MessagingException: 550 Access denied - Invalid HELO name (See RFC2821 4.1.1.1)"
by the way, I have already set my mail.smtp.auth property to true as : props.put("mail.smtp.auth", "true"), but it still fail, does anyone has idea? or face similar problem before ?

A 550 error is often returned by the SMTP server when the sending hostname cannot be inverse resolved to the originating IP address. This allows mail servers a bit of authentication that the sending client is who it says it is. Unfortunately, many test clients - especially systems behind a NAT device - will have originating IP addresses that don't map to any name.
For example, the machine I am typing this on has an unroutable IP address of 192.168.1.103 and my hostname could be so.example.myhouse which works fine because my router pretends that packets from my desk come from (e.g.) 69.59.196.211 which is my WAN address. However, if you use a props.put("mail.from", "me#so.example.myhouse") the SMTP server may try a DNS lookup and obviously fail for my fictional hostname (that is, one that the global DNS doesn't know of).
Even if I used the DNS name which maps to 69.59.196.211 (e.g. stackoverflow.com) the SMTP server may do a reverse DNS lookup to check that 211.196.59.69.in-addr.arpa maps to stackoverflow.com. If that fails, the SMTP server may consider you a spoofer and return a 550.
Finally, your sending client or every host it its IP address block could be blacklisted by the SMTP server for reasons that you have no control over.
Without more context than you probably want to post (names and addresses of the guilty client and server) I can't be sure that it is an SMTP/DNS problem unrelated to Java so you'll have to check those bits yourself. You can skip the Java altogether and telnet smtp-servername 25 and talk to the server yourself. You'll find RFC 2821 helpful should you try.

replace
props.put("mail.smtp.auth", true);
to
props.put("mail.smtp.auth", "true");
and it works :)

Related

How do I resolve a SOAPFaultException with Hostnameverifier socket reset for TTL error message?

I have successfully built a client and server (Jetty) over localhost. This means I launched the Jetty server (https://localhost:8444/ws) and ran the client locally on the same machine and the entire handshake process worked perfectly.
When the client and server run on different machines, the following error message is received:
Caused by: java.lang.RuntimeException : socket reset for TTL
at org.apache.cxf.transport.https.HttpsClient.DefaultHostnameVerifier.verify(DefaultHostnameVerifier.java:98)
at sun.net.www.protocol.https.HttpsClient.checkURLSpoofing(Https.Client.java:641)
at sun.net.www.protocol.https.HttpsClient.afterConnect(Https.Client.java:573)
at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.connect(AbstractDelegateHttpsURLConnection.java:185)
...
**Update: ** in response to Stefan D's question below: By separating both the client and server from each other, I mean to simply move the WAR file to another linux host with IP address XXX.YYY.ZZZ.abc and the client to a different linux host with IP address XXX.YYY.ZZZ.def.
TLS compares the hostname given in the URL for connection against the CN in the certificate. A mismatch leads to the error you struggeling on.
To satisfie this requirement, the parameter CN of the subject (owner) in the certificate must exactly match the DNS hostname whitch is configured to the IP address of your server.
I.e. if the machine with IP address XXX.YYY.ZZZ.abc has the DNS name flintstone than the CN (which is set during generation of CSR) must be set to flintstone. If the DNS name is located in a different zone than the FQDN must be used.
The subject (owner) CN of your certificate is root.localhost. I presume that this is not the DNS name of the machine. So as explained above the hostname verification fails.
If you create your own certificates than it is possible to use an IP address as CN but for certificates ordered by a trust center it's no more supported. Also you may face the fact that self signed certificates are refused. For this, a lot of tools (freeware/open source and commercial) can be found in the internet.

own java mail client & yandex smtp server - javax.mail.AuthenticationFailedException

evening,
i'm trying to do my own email client and then error came.
im using javax.mail library
i did try several methods for sending, most of them crash on sad places. anyway, one method i consider with potential is fine until end when message pops up:
m02 error-2: javax.mail.AuthenticationFailedException: 535 5.7.8 Error: authentication failed: Your message looks like spam. You need to use web for sending or prove you are not a robot using the following link http://ya.cc/[deleted] where [deleted] is originally few letters string.
i saw with gmail, you need to set something in settings to be able to use your own client, i expected this would be similar case but i couldn't find any settings about it in yandex mailbox settings.
another point, smtp address i have found at some forum so i presume it is possible to use own client
properties i set:
properties.put("mail.smtp.host", host);
properties.put("mail.smtp.socketFactory.port", port_ssl);
properties.put("mail.smtp.socketFactory.class", "javax.net.ssl.SSLSocketFactory");
properties.put("mail.smtp.auth", "true");
properties.put("mail.smtp.port", port_ssl);
where
private String host = "smtp.yandex.com";
private String port_ssl = "465";
other code, im using classic way: Session for Authenticator, then Message and Transport.send. anyway, i think problem is with properties or mailbox settins? i just cant think of where.
question: how can i fix it so i can send an email with my client?
note: reason for using yandex is thanks to simple sign up since i dont have phone number and gmail requires one. if you know about other email service where own client should work & no need for phone that is also nice alternative answer
As an alternative answer, you could try the service https://protonmail.com, it should not require phone number and it can be reachable by SMTP clients using these settings https://mailsettings.co/protonmail-smtp-server-settings

Simple Java Mail SMTP host

I am using Simple Java Mail API in order to send emails from my Spring Boot application. The app's owner was my colleague who doesn't work with me now. In my application.properties file I have the following config
simplejavamail:
smtp:
host: 172.28.94.229
port: 25
javaxmail:
The question is that I can't understand what host is this? Which server my emails go to? Is this something provided by Simple Java Mail, but I couldn't find anything in their documentation.
This IP address is not publicly routable on the Internet but is reserved and used for private or local networks.
For you information the following IPv4 address spaces are not Internet routable:
10.0.0.0/8 IP addresses: 10.0.0.0 – 10.255.255.255
172.16.0.0/12 IP addresses: 172.16.0.0 – 172.31.255.255
192.168.0.0/16 IP addresses: 192.168.0.0 – 192.168.255.255
You can try the following command
telnet 172.28.94.229 25
and see if you get a timeout (meaning that no service is listening on that IP/Port) or you are connected to some service.
If this IP/Port exists and you get a connection opened, then you should ask your company's system admin for more information on that SMTP server.
If you cannot get connected, maybe this is just a mock / not real SMTP server.

Send mail to #hotmail.com/#live.com with JavaMail

I develop a application on android to send email. I want to use account MSN to send mail but it not send and error code on debug as below:
My configure on property are:
systemProperty.put("mail.smtp.starttls.enable","true");
systemProperty.put("mail.smtp.auth", "true");
systemProperty.setProperty("mail.host", "smtp.live.com");
systemProperty.put("mail.smtp.port", "587");
The password and email address are correct and i ever test with other host are work except MSN.
It looks like JavaMail isn't able to figure out your host name correctly, although I don't know why it would think "????" is your host name. Set the mail.smtp.localhost property to the correct host name for your machine. See the javadocs for the com.sun.mail.smtp package for details.
There seems nothing wrong with your configuration. 501 5.5.4 Invalid Address can be occuring because of the possible reasons below
The To email address is wrong in format (like check if it violates the possible combinations of email addresses. Eg., "My Name" - try simplifying it to myname#live.com and try
It might be bouncing email address
Check the library you use for sending this, how and what it allows

Transport not work for sending smtp email in java

I am using :
transport.connect(getHost(), getPort(), getUsername(), getPassword());
to send email, but it always gives me the following exception:
class com.sun.mail.smtp.SMTPAddressFailedException: 503 This mail server requires authentication when attempting to send to a non-local e-mail address. Please check your mail client settings or contact your administrator to verify that the domain or address is defined for this server.
But actually I have provided the username and password above, and the username and password is right as I tested in thunderbird, it can send email well.
So what's my problem ? Please point me the right direction. Thanks
When creating the javax.mail.Session, be sure the given properties contain:
props.put("mail.smtp.auth", "true");
http://www.oracle.com/technetwork/java/javamail/faq/index.html#smtpauth
I think that you need to talk to the administrators of the mail server to see what is going on. You might be using the wrong port for instance. Or there might be some local policy that you need to observe ...

Categories

Resources