2010-03-25 166 views

回答

3

怎么样一个开源电子邮件客户端的黑莓。使用gmail的smtp服务器和句柄的TSL/SSL认证没有问题没有问题。

它恰好是RIM尚未发现的黑莓最受欢迎的开源电子邮件客户端。

这里是一个页面,从中可以下载它,并尝试它,或得到所有的源代码。 http://www.logicprobe.org/proj/logicmail

+0

嗨Vernom,谢谢你的回复但我必须在我的应用程序中通过smpt以编程方式发送电子邮件(应用程序不是电子邮件客户端) – Alex 2010-03-25 19:51:56

+0

这就是开源的全部要点。 LogicMail做你想做的一切,你可以看看它的源代码。基本上有两个问题需要解决:打开SSL网络连接并说SMTP协议。 – octo 2010-03-25 20:59:37

+0

许可证怎么样?我可以在非开源项目中使用它吗?我阅读了BSD许可证,但不清楚我是否可以使用或不使用闭源项目 – Alex 2010-03-26 07:17:34

0

有在Java中发送邮件一个lib,它叫做JavaMail。我不知道这是否可以与黑莓手机使用,但如果是后者的话,只需要使用这个类:

import javax.mail.*; 
import javax.mail.internet.InternetAddress; 
import javax.mail.internet.MimeMessage; 
import java.util.Properties; 

public class MailUtils { 
    private MailUtils() { 
    } 

    public static void sendSSLMessage(String recipients[], String subject, 
          String message, String from) throws MessagingException { 
     boolean debug = true; 
     Properties props = new Properties(); 
     props.put("mail.smtp.host", "smtp.gmail.com"); 
     props.put("mail.smtp.auth", "true"); 
     props.put("mail.debug", "true"); 
     props.put("mail.smtp.port", "465"); 
     props.put("mail.smtp.socketFactory.port", "465"); 
     props.put("mail.smtp.socketFactory.class", "javax.net.ssl.SSLSocketFactory"); 
     props.put("mail.smtp.socketFactory.fallback", "false"); 
     Session session = Session.getDefaultInstance(props, 
      new javax.mail.Authenticator() { 
       protected PasswordAuthentication getPasswordAuthentication() { 
        return new PasswordAuthentication("[email protected]", "your password"); 
        } 
       } 
     ); 
     session.setDebug(debug); 
     Message msg = new MimeMessage(session); 
     InternetAddress addressFrom = new InternetAddress(from); 
     msg.setFrom(addressFrom); 
     InternetAddress[] addressTo = new InternetAddress[recipients.length]; 
     for (int i = 0; i < recipients.length; i++) { 
      addressTo[i] = new InternetAddress(recipients[i]); 
     } 
     msg.setRecipients(Message.RecipientType.TO, addressTo); 
// Setting the Subject and Content Type 
     msg.setSubject(subject); 
     msg.setContent(message, "text/plain"); 
     Transport.send(msg); 
    } 
} 
+0

这不会对黑莓手机的工作 - 那些javax.mail *类不可用J2ME。 – 2010-03-25 17:07:00

+0

好的,对不起。你想让我删除我的答案吗? – mindas 2010-03-25 17:18:29

+0

Martoc Novakowski有权利,我尝试了一切,我来到我的脑海里...我在网上看到一个解决方案,但我不知道它会工作,这是有点贵.. – Alex 2010-03-25 19:51:10

相关问题