Transport not work for sending smtp email in java - 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 ...

Related

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

Transport.send is not working

While trying to use
Transport.send(message, addresses); or transport.sendMessage(message, message.getAllRecipients());
while sending mail using java, the process never ends only when I provide wrong password for my attachment file.
Tried some solutions from below links but does not help:
Link 1:
Link 2:
Interestingly, process hangs only when I am providing wrong password for the attachment. While it works when I provide correct password for the attachment. Attached file is from SFTP server.
Using gmail SMTP account to send an email:
Server domain: smtp.gmail.com
Port: 465
Secure Connection: SSL
Anyone having any thoughts will be appreciated.

How to create multiple user in BIM server ? Version : 1.3.0-RC6-2014-03-14

I am new in BIM Server , trying to figure out how BIM server and IFC model sync together.
I made connectivity to local BIM-server from a java application. I use the default settings as described in https://github.com/opensourceBIM/BIMserver/wiki/Setup .
Now, when I am going to create a new user it only ask for mail address , username and Access level. No password field . So, I can not do log in using that user.
"Send Password Reset" is giving the following error :
" Could not connect to SMTP host: localhost, port: 25 (java.net.ConnectException: Connection refused: connect) " .
Whether it is a BIM server version problem or I am missing something ?
I have not found any well prepared Documentation or tutorial on BIM server. My goal is to check how the BIM server can replace the ftp server that we are using now to store IFC files.
Thanks in advance
-Nazar-E-Bukhari
I have posted this in BIM server Issues. I am posting the answer if someone is also searching for the same solution.
"It's really bad practice to have an administrator set the user's passwords. How is the administrator going to give the passwords to those users? (I agree with him, but as because I am testing it in my localhost, I have no mail server configured)
Setup a working e-mail server, or better yet, use a third party's server. For example have a look at mailgun, sendgrid or postmark."

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

Java Mail Exception

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 :)

Categories

Resources