使用JavaMail发送邮件

时间:2013-01-30 14:00:27

标签: java javamail

我有下一个问题,发送带有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,很奇怪。

我做错了什么?非常感谢

0 个答案:

没有答案