身份验证失败:digitalocean邮件服务器中的常规故障

时间:2018-02-20 01:46:56

标签: java email smtp javamail digital-ocean

我正在尝试发送电子邮件,但它没有发送出去。每次我收到错误"身份验证失败:泛型失败"。

以下是我的代码。我不知道我在这里失踪了什么。

    @Test
public void test() {
    BaseMail mail = MailFactory.getMail();
    mail.setFrom("myfrom@mail.domainname.com");
    mail.setTo("to@domainname.com");
    mail.setPersonal("Test");
    mail.setSubject("Test Email");
    mail.setContent("Test Email");          
    try {
        Transport.send(getMessage(mail));
    } catch (MessagingException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }       
}

public static Session getSession(){
    if(session == null){
        Properties props = new Properties();
        TKAuthenticator auth = null;
        try {
            props.put("mail.smtp.host","mail.mydomain.com");
            props.put("mail.smtp.port","587");
            props.put("mail.smtp.auth","true");
            props.put("mail.debug","true");
            props.put("mail.smtp.from","bounce@mail.mydomain.com");
            auth = new TKAuthenticator("username@mail.mydomain.com", "password");

        session = Session.getInstance(props, auth);
        session.setDebug(true);         

    }
    return session;
}   

这是我的日志:

DEBUG: setDebug: JavaMail version 1.4.1ea-SNAPSHOT
DEBUG: getProvider() returning         javax.mail.Provider[TRANSPORT,smtp,com.sun.mail.smtp.SMTPTransport,Sun     Microsystems, Inc]
DEBUG SMTP: useEhlo true, useAuth true
DEBUG SMTP: useEhlo true, useAuth true
DEBUG SMTP: trying to connect to host "mail.mydomain.com", port 587, isSSL     false
220 mail.mydomain.com ESMTP Postfix
DEBUG SMTP: connected to host "mail.mydomain.com", port: 587
250-mail.mydomain.com
250 DSN
DEBUG SMTP: Found extension "PIPELINING", arg ""
DEBUG SMTP: Found extension "SIZE", arg "10240000"
DEBUG SMTP: Found extension "DSN", arg ""
DEBUG SMTP: Attempt to authenticate
AUTH LOGIN
334 FADSF
Z3N1c2VyQFADSFADFAG1haWZnNtYXNoLmNvbQ==
334 QFVDASVCV
FADSIFOIA FOIADI FAF==
535 5.7.8 Error: authentication failed: generic failure
javax.mail.AuthenticationFailedException

请试着看看。

0 个答案:

没有答案