JavaMail No authentication Mechansims supported by both server and client when sending mail

Source: Internet
Author: User
Tags auth server port

Project requirements to replace the outgoing mail server, change to a transit mailbox server to send mail. The results are always reported to No authentication Mechansims supported by both server and client.

Search a bunch of things, are not reliable finally self-debugging success. Refer to the following URL:

Http://stackoverflow.com/questions/8615730/javamail-with-ms-exchange-no-authentication-mechansims-supported-by-both-server

Reason: The relay server does not need to verify the user name password what, so when the link

Mail_smtp_auth should be set to false.

Transport.connect ()///transit server mailbox do not pass anything, even if it is null or empty, when the connection is not verified. It will think you want to verify.

(First make sure your outgoing mail server and application server are figured out.) and the mail server port is correct, default is (Telnet 192.168.1.114 25))

Javax.mail.AuthenticationFailedException:No authentication Mechansims supported by both server and client at COM.S Un.mail.smtp.SMTPTransport.authenticate (smtptransport.java:765) at Com.sun.mail.smtp.SMTPTransport.protocolConnect (smtptransport.java:685) at Javax.mail.Service.connect ( service.java:274) at Javax.mail.Service.connect (service.java:91) at Com.zhaopin.common.mail.util.MailSendUti L.<clinit> (mailsendutil.java:108) at Com.zhaopin.cdcpm.thread.MailThread.run (mailthread.java:17) ========== =======begin send mail=======================15:06:31,232 ERROR [Com.zhaopin.common.mail.util.MailSendUtil] ( com.zhaopin.common.mail.util.mailsendutil:155)-When sending mail, here catch exception!!!!! Javax.mail.AuthenticationFailedException:No authentication Mechansims supported by both server and client at COM.S Un.mail.smtp.SMTPTransport.authenticate (smtptransport.java:765) at Com.sun.mail.smtp.SMTPTransport.protocolConnect (Smtptransport.java:685) at Javax.mail.Service.connect (service.java:274) at Javax.mail.Service.connect (Service.java: In Com.zhaopin.common.mail.util.MailSendUtil.send (mailsendutil.java:135) at Com.zhaopin.cdcpm.thread.Mai Lthread.run (mailthread.java:17) javax.mail.AuthenticationFailedException:No authentication mechansims supported by Both server and client at Com.sun.mail.smtp.SMTPTransport.authenticate (smtptransport.java:765) at com.sun.ma        Il.smtp.SMTPTransport.protocolConnect (smtptransport.java:685) at Javax.mail.Service.connect (service.java:274) At Javax.mail.Service.connect (service.java:91) at Com.zhaopin.common.mail.util.MailSendUtil.send (Mailsendutil.jav a:135) at Com.zhaopin.cdcpm.thread.MailThread.run (mailthread.java:17)

static {Log.info ("-----Start init Mail Environment-----"); Authenticator auth = new Authenticator () {protected passwordauthentication getpasswordauthentication () {return new Passwordauthentication (Mailconfig.getmailfromusername (), mailconfig.getmailfromuserpswd ());}; Properties Props = new property ();//Set the attribute Props.put (Mail_smtp_host, Mailconfig.getmailhost ()) of the mail server that sent the message;//need to be authorized, That is, the user name and password verification, so as to pass verification (must have this) Props.put (Mail_smtp_auth, Mailconfig.isvalidate ());//Build a session//with the props object you just set Session = Session.getdefaultinstance (props, auth), session = Session.getdefaultinstance (props, null);//transit server mailbox does not validate try { Send mail transport = Session.gettransport ("SMTP"),///connection to the server's mailbox//transport.connect (Mailconfig.getmailhost (), Mailconfig.getmailfromusername (), mailconfig.getmailfromuserpswd ()); Transport.connect ();//transit server mailbox does not validate Log.info ("- ----Connect with "+ mailconfig.getmailhost () +" successfully-----");} catch (Exception e) {log.error ("-----Connect with" + mailconfig.getmailhost () + "failed-----", e);}} 

  

JavaMail No authentication Mechansims supported by both server and client when sending mail

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.