Could not connect to SMTP Host:localhost, port:25;

Source: Internet
Author: User

1. Error description

DEBUG:setDebug:JavaMail version 1.3.3debug:getprovider () returning JAVAX.MAIL.PROVIDER[TRANSPORT,SMTP,  Com.sun.mail.smtp.smtptransport,sun Microsystems, Inc]debug Smtp:useehlo True, Useauth TrueDEBUG smtp:trying to connect To host ' localhost ', port, Isssl falseexception in thread ' main ' javax.mail.MessagingException:Could not connect to S MTP Host:localhost, port:25;  Nested exception is:java.net.ConnectException:Connection Refused:connectat Com.sun.mail.smtp.SMTPTransport.openServer (smtptransport.java:1227) at Com.sun.mail.smtp.SMTPTransport.protocolConnect (smtptransport.java:322) at Javax.mail.Service.connect ( service.java:236) at Javax.mail.Service.connect (service.java:137) at Com.you.mail.model.SendMessage.sendMessage ( SENDMESSAGE.JAVA:70) at Com.you.mail.model.SendMessage.main (sendmessage.java:89)

2. Cause of error

Unable to connect to SMTP service host from error


3. Solutions

Configure the correct SMTP service host to ensure that the service is connected

String Server = "smtp.163.com"; String username = ""; String password = ""; Transport Transport = Session.gettransport () transport.connect (server, username, password); Transport.sendmessage ( Message, message.getrecipients (Message.RecipientType.TO)); Transport.close ();


Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

Could not connect to SMTP host:localhost, port:25;

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.