This week's book giveaway is in the Agile and other Processes forum.
We're giving away four copies of The Mikado Method and have Ola Ellnestam and Daniel Brolund on-line!
See this thread for details.
The moose likes Other JSE/JEE APIs and the fly likes Sending Mail using Java Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » Other JSE/JEE APIs
Reply Bookmark "Sending Mail using Java" Watch "Sending Mail using Java" New topic
Author

Sending Mail using Java

Jayavardhan Ncbr
Greenhorn

Joined: Jul 25, 2011
Posts: 9
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

Joined: Jul 26, 2007
Posts: 8434

What error did you get? Can you post the stack trace?


[Donate a pint, save a life!] [How to ask questions] [Onff-turn it on!]
Jayavardhan Ncbr
Greenhorn

Joined: Jul 25, 2011
Posts: 9
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

Joined: Jul 26, 2007
Posts: 8434

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

Joined: Jul 25, 2011
Posts: 9
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

Joined: Jul 26, 2007
Posts: 8434

Maneesh Godbole wrote:Is there an SMTP server running at that IP and port?
Angus Comber
Ranch Hand

Joined: Jul 16, 2011
Posts: 88
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

Joined: Aug 05, 2011
Posts: 50

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.


Java Object Creation
H Paul
Ranch Hand

Joined: Jul 26, 2011
Posts: 299
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.


 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: Sending Mail using Java
 
Similar Threads
How to identify whether the mail is read or not
Error in Jakarta JAMES Mail Server
how to display a image file comming as attachment
javax.mail.Internet.parseException
Java Mail