• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

Sending Mail using Java

 
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Bartender
Posts: 11497
19
Android Google Web Toolkit Mac Eclipse IDE Ubuntu Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Bartender
Posts: 11497
19
Android Google Web Toolkit Mac Eclipse IDE Ubuntu Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Bartender
Posts: 11497
19
Android Google Web Toolkit Mac Eclipse IDE Ubuntu Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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

 
Ranch Hand
Posts: 90
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 50
Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 491
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.


 
Alas, poor Yorick, he knew this tiny ad:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic