Hi i would like to send a simple mail using java.. So i downloaded mail.jar and activation.jar file and i wrote simple program to send it.
My Simple mail program compiles successfully.. But when i run it shows the following error.
javax.mail.MessagingException: Could not connect to SMTP host: localhost, port: 25; nested exception is: java.net.ConnectException: Connection refused: connect
My doubt is how to find the SMTP server name for my PC? I searched in site but didnt get anything clearly..
Please make me to travel in a right direction...
With regards
Xavier KCB
SMTP is an acronym for Simple Mail Transfer Protocol. It is an Internet standard for electronic mail (e-mail) transmission across Internet Protocol (IP) networks.
Class MimeMessage. This class represents a MIME style email message. It implements the Message abstract class and the MimePart interface. Clients wanting to create new MIME style messages will instantiate an empty MimeMessage object and then fill it with appropriate attributes and content.
For sending email with attachment, JavaMail API provides some useful classes like BodyPart, MimeBodyPart etc. For better understanding of this example, learn the steps of sending email using JavaMail API first. For sending the email using JavaMail API, you need to load the two jar files: mail.
You don't have to use SMTP server name for your PC, you have to use external email server, for example, gmail, yahoo, etc. You can set up mail server on you computer, but it is out of the question. In your case, you have to register new email in free mail system, and use it smtp server and port. You can google more about JavaMail API examples: cafeaulait, vipan
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With