Forums Register Login

Sending Email using Java gives error message

+Pie Number of slices to send: Send
Hi,
I am using java application to send email.
My Email server is "Godaddy.com".
host is smtpout.secureserver.net
port is : 25
when I use gmail(smtp.gmail.com) it works fine, but using godaddy I can't send mail
this is my code:


-----------------------------------------------------------------------

Security.addProvider(new com.sun.net.ssl.internal.ssl.Provider());
Properties props = new Properties();
props.setProperty("mail.transport.protocol", "smtp");
props.setProperty("mail.host", "relay-hosting.secureserver.net");
props.put("mail.smtp.auth", "true");
props.put("mail.smtp.port", "25");
props.put("mail.smtp.socketFactory.port", "25");
//props.put("mail.smtp.socketFactory.class","javax.net.ssl.SSLSocketFactory");
props.put("mail.smtp.socketFactory.fallback", "false");
props.setProperty("mail.smtp.quitwait", "false");

Session session = Session.getDefaultInstance(props,
new javax.mail.Authenticator()
{
protected PasswordAuthentication getPasswordAuthentication()
{ return new PasswordAuthentication("username@xx.com","pass"); }
});

MimeMessage message = new MimeMessage(session);
message.setSender(new InternetAddress("vinoth@clss.in"));
message.setSubject("test");
message.setContent("Hi pon", "text/html");
message.setRecipient(Message.RecipientType.TO, new InternetAddress("xxxx@clss.in"));
Transport.send(message);

---------------------------------------------------------------------------------------------------------------------------------------------------------

I get Error message like this:
--------------------------------------

javax.mail.SendFailedException: Invalid Addresses;
nested exception is:
com.sun.mail.smtp.SMTPAddressFailedException: 553 sorry, relaying denied from your location [115.117.232.45] (#5.7.1)

at com.sun.mail.smtp.SMTPTransport.rcptTo(SMTPTransport.java:1835)
at com.sun.mail.smtp.SMTPTransport.sendMessage(SMTPTransport.java:1098)
at javax.mail.Transport.send0(Transport.java:195)
at javax.mail.Transport.send(Transport.java:124)
at Mailing.SendMail.clss_sendMail(SendMail.java:107)
at Mailing.SendMail.main(SendMail.java:31)
Caused by: com.sun.mail.smtp.SMTPAddressFailedException: 553 sorry, relaying denied from your location [115.117.232.45] (#5.7.1)

at com.sun.mail.smtp.SMTPTransport.rcptTo(SMTPTransport.java:1686)
... 5 more



any idea please?
+Pie Number of slices to send: Send
Even i have faced this error invalid address error was coming because of from addres
so make sure that from adress field will be same,as what you have authenticated..


and before saying
transport.send(message);

First get the transport protocol using...
Transport transport = session.getTransport("smtp");
+Pie Number of slices to send: Send
hi Shanky Sohar,

i checked that sender and the authentication email ids are same.
and i have added this line

Transport transport = session.getTransport("smtp");

still i get the same error.
1
+Pie Number of slices to send: Send
See that error message, "553 sorry, relaying denied from your location"? That means that you're connecting perfectly. The problem is after that - you are trying to relay, and that's not allowed with this SMTP server. The problem is not in your code but in the server configuration.
1
+Pie Number of slices to send: Send
Why not you try using IP Address,Instead of host name.I hope it will work fine.

Otherwise raise a ticket request on godaddy.com..about the issue as you may not be having a server access..
+Pie Number of slices to send: Send
 

Why not you try using IP Address,Instead of host name.I hope it will work fine.


Why would it? As Rob pointed out, connectivity is not the problem.
+Pie Number of slices to send: Send
 

Ulf Dittmer wrote:

Why not you try using IP Address,Instead of host name.I hope it will work fine.


Why would it? As Rob pointed out, connectivity is not the problem.



Yes you are right..Connectivity is working fine..but here is the solution.
"The email program you already use for sending and receiving messages can easily be used along with the server just by using the IP address "127.0.0.1" instead of your current SMTP host"

source is
http://www.softheap.com/smtprelay.html

just giving a try to solve it..May be it works with a IP.
+Pie Number of slices to send: Send
You fundamentally misunderstand what the page you linked to is talking about; it's about running a local mail server - that's hardly the sort of solution vinoth Robert is looking for.
+Pie Number of slices to send: Send
hi friends,

how to set ip address instead of host name?

OR

can any one give me the code which works correctly in Godaddy server(relay-hosting.secureserver.net)?
+Pie Number of slices to send: Send
just write IP address instead of host name nothing else..
+Pie Number of slices to send: Send
Finally I got it.

the Code is

public void sendMail() throws Exception
{
try
{
Properties props = System.getProperties();
props.setProperty("mail.transport.protocol", "smtp");
props.setProperty("mail.host", "relay-hosting.secureserver.net");

props.put("mail.smtp.auth", "true");
props.setProperty("mail.user", "xxxxxx@xxxx.com");
props.setProperty("mail.password", "password");

Session mailSession = Session.getDefaultInstance(props, null);
mailSession.setDebug(true);
Transport transport = mailSession.getTransport("smtp");
MimeMessage message = new MimeMessage(mailSession);
message.setSentDate(new java.util.Date());
message.setSubject("Hi Test");
message.setFrom(new InternetAddress("xxxxx@xxxx.com"));
message.setRecipient(Message.RecipientType.TO, new InternetAddress("toxxx@xxxx.com"));
MimeMultipart multipart = new MimeMultipart("related");
// first part (the html)
BodyPart messageBodyPart = new MimeBodyPart();
messageBodyPart.setContent("Hi rsgdsdgdfgsdfg", "text/html");

// add it
multipart.addBodyPart(messageBodyPart);
// put everything together
message.setContent(multipart);

transport.connect("relay-hosting.secureserver.net", "xxxxxxx@xxx.com","password");
transport.sendMessage(message, message.getRecipients(Message.RecipientType.TO));
transport.close();

}
catch (Exception e) {
e.printStackTrace();
}
}
+Pie Number of slices to send: Send
Vinoth Robert, hasn't anyone told you you should UseCodeTags instead of colouring? If not, then now someone has
+Pie Number of slices to send: Send
Remember using getDefaultInstance will create a shared session that can be used by other application too.


So its better to use a connection dedicated to your application.Use

+Pie Number of slices to send: Send
thanks Shanky Sohar.
+Pie Number of slices to send: Send
 

vinoth Robert wrote:thanks Shanky Sohar.



Most welcome
+Pie Number of slices to send: Send
Thanks Vinoth:

This is what worked for me (code below). I needed port 80, which was the main trick:

(the email I sent DID come into my spam account on google, but still, that was a successful send)

Why am I so drawn to cherry pie? I can't seem to stop. Save me tiny ad!
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com


reply
reply
This thread has been viewed 18281 times.
Similar Threads
send mail in java "relay" problem
Sending Email in java through MS Exchange Server
Java Mail
Not able To Send Mail Outside Of Domain Name
How to send a mail to different email id
Email send failure
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 23:22:54.