0

我在使用 Java 发送电子邮件时遇到了下一个问题,我不知道为什么。做一个调试我得到了这个,我不知道为什么。跟踪错误的痕迹是这样的:

DEBUG: JavaMail version 1.4.5
DEBUG: successfully loaded resource: /META-INF/javamail.default.providers
DEBUG: Tables of loaded providers
DEBUG: Providers Listed By Class Name: {com.sun.mail.smtp.SMTPSSLTransport=javax
.mail.Provider[TRANSPORT,smtps,com.sun.mail.smtp.SMTPSSLTransport,Sun Microsyste
ms, Inc], com.sun.mail.smtp.SMTPTransport=javax.mail.Provider[TRANSPORT,smtp,com
.sun.mail.smtp.SMTPTransport,Sun Microsystems, Inc], com.sun.mail.imap.IMAPSSLSt
ore=javax.mail.Provider[STORE,imaps,com.sun.mail.imap.IMAPSSLStore,Sun Microsyst
ems, Inc], com.sun.mail.pop3.POP3SSLStore=javax.mail.Provider[STORE,pop3s,com.su
n.mail.pop3.POP3SSLStore,Sun Microsystems, Inc], com.sun.mail.imap.IMAPStore=jav
ax.mail.Provider[STORE,imap,com.sun.mail.imap.IMAPStore,Sun Microsystems, Inc],
com.sun.mail.pop3.POP3Store=javax.mail.Provider[STORE,pop3,com.sun.mail.pop3.POP
3Store,Sun Microsystems, Inc]}
DEBUG: Providers Listed By Protocol: {imaps=javax.mail.Provider[STORE,imaps,com.
sun.mail.imap.IMAPSSLStore,Sun Microsystems, Inc], imap=javax.mail.Provider[STOR
E,imap,com.sun.mail.imap.IMAPStore,Sun Microsystems, Inc], smtps=javax.mail.Prov
ider[TRANSPORT,smtps,com.sun.mail.smtp.SMTPSSLTransport,Sun Microsystems, Inc],
pop3=javax.mail.Provider[STORE,pop3,com.sun.mail.pop3.POP3Store,Sun Microsystems
, Inc], pop3s=javax.mail.Provider[STORE,pop3s,com.sun.mail.pop3.POP3SSLStore,Sun
Microsystems, Inc], smtp=javax.mail.Provider[TRANSPORT,smtp,com.sun.mail.smtp.S
MTPTransport,Sun Microsystems, Inc]}
DEBUG: successfully loaded resource: /META-INF/javamail.default.address.map

DEBUG: getProvider() returning javax.mail.Provider[TRANSPORT,smtp,com.sun.mail.s
mtp.SMTPTransport,Sun Microsystems, Inc]
DEBUG SMTP: useEhlo true, useAuth false
DEBUG SMTP: trying to connect to host "smtp.businesscloud.es", port 465, isSSL f
alse

执行此操作的代码就是这样,只是我执行此操作的一个简单函数:

String[] lista_envio = enviar_a.split(";");

        String smtpHost = "smtp.businesscloud.es";
        Properties props = System.getProperties();
        props.put("mail.smtp.host",smtpHost);
        props.put("mail.smtp.port", 465);  
        props.put("mail.smtp.user", "");
        props.put("mail.smtp.password","");
        props.put("mail.debug", "true");
        Session sesion = Session.getDefaultInstance(props,null);

        Message correo = new MimeMessage(sesion);

        correo.setSubject(asunto.trim().toUpperCase());

        correo.setFrom(new InternetAddress(enviado_por));

        for (int i = 0; i < lista_envio.length; i++)
        {
           System.out.println("Dentro del for de enviar_correos");
            correo.addRecipient(Message.RecipientType.TO, new InternetAddress(lista_envio[i]));
        }

        correo.setText(cuerpo);
        correo.addHeader("X-Priority", "3");





        System.out.println("Voy a mandar el mail");
        Transport.send(correo);

发送后我遇到的异常是:未知的 SMTP 主机:smtp.businesscloud.es,这很奇怪。

我做错了什么?非常感谢

4

0 回答 0