Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Sending Mail using Java

 
Jayavardhan Ncbr
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I am new to Java.

I want to know how to send Mail message using Java.

Can any one tell me the steps.


I used Java Mail sample source code , but i am getting error at transport.send().

Thanks in advance
 
Maneesh Godbole
Saloon Keeper
Posts: 11178
15
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What error did you get? Can you post the stack trace?
 
Jayavardhan Ncbr
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Maneesh Godbole wrote:What error did you get? Can you post the stack trace?



Hi,

This is the error i got.


--Exception handling in msgsendsample.java
javax.mail.SendFailedException: Sending failed;
nested exception is:
class javax.mail.MessagingException: Could not connect to SMTP host: 10.40.9.50, port: 25, response: 421



at javax.mail.Transport.send0(Transport.java:218)
at javax.mail.Transport.send(Transport.java:80)
at Emailmsg.main(Emailmsg.java:43)
 
Maneesh Godbole
Saloon Keeper
Posts: 11178
15
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is there an SMTP server running at that IP and port? Do you have a firewall running (which is probably blocking the port access)
 
Jayavardhan Ncbr
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Maneesh Godbole wrote:Is there an SMTP server running at that IP and port? Do you have a firewall running (which is probably blocking the port access)


Hi,

No. firewall is off.

 
Maneesh Godbole
Saloon Keeper
Posts: 11178
15
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Maneesh Godbole wrote:Is there an SMTP server running at that IP and port?
 
Angus Comber
Ranch Hand
Posts: 90
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
To check your SMTP server you can use telnet commands to test how to send your email.

eg telnet hostname 25

HELO <domainname>

Maybe the smtp server requires special authentication.
 
Nam Ha
Ranch Hand
Posts: 50
Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Notice the response code:

class javax.mail.MessagingException: Could not connect to SMTP host: 10.40.9.50, port: 25, response: 421


According to SMTP spec:

421: Service not available, closing transmission channel


That means there is a server at the specified IP but it does not have SMTP service.
 
H Paul
Ranch Hand
Posts: 471
4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If this help:

1. I used Apache common mail.

2. For one open wifi A, I can send the mail perfectly.

3. With the same code, I have the same issue with anothe open wifi B (see below error). So somewhere, there is a blockage in the wifi B. I am interest to know what/where exactly is.


 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic