Tag: email

Exchange服务器不接受javax.mail API提供的用户名/密码

我有一个可爱的小Java客户端发送签名的电子邮件。 我们有一台Exchange服务器,需要用户名/密码validation才能发送邮件。 当我连接到Exchange服务器时,我收到此错误: avax.mail.AuthenticationFailedException: failed to connect at javax.mail.Service.connect(Service.java:322) at javax.mail.Service.connect(Service.java:172) 当我连接到其他服务器(Unix服务器)时,我没有问题。 以下是完整的调试跟踪。 我无法弄明白。 DEBUG: JavaMail version 1.4.2 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.SM} DEBUG: Providers Listed By Protocol: {imaps=javax.mail.Provider[STORE,imaps,com.sun.mail.imap.IMAPSSLStore,Sun Microsystems, Inc], } DEBUG: successfully loaded resource: /META-INF/javamail.default.address.map DEBUG: getProvider() returning javax.mail.Provider[TRANSPORT,smtp,com.sun.mail.smtp.SMTPTransport,Sun Microsystems, Inc] […]

使用Spring电子邮件抽象层阅读邮件

Spring提供了JavaMail Api的抽象。 有很多例子可以描述如何使用spring email abstraction layer发送邮件。 但我怎么能用这个阅读电子邮件呢?

TLS上的Java Mail

我试图通过TLS连接从我的程序发送电子邮件。 这是我的代码 final String username = “XXXXXX”; final String password = “XXXXX”; Properties props = new Properties(); props.put(“mail.transport.protocol”, “smtp”); props.put(“mail.smtp.starttls.enable”,”true”); props.put(“mail.smtp.auth”, “true”); props.put(“mail.smtp.host”, “mail.xxxx.com”); props.put(“mail.smtp.port”, “587”); Session session = Session.getInstance(props, new javax.mail.Authenticator() { protected PasswordAuthentication getPasswordAuthentication() { return new PasswordAuthentication(username, password); } }); Message message = new MimeMessage(session); message.setFrom(new InternetAddress(“from@xxxx.com”)); message.setRecipients(Message.RecipientType.TO, InternetAddress.parse(to_address)); message.setSubject(“Test Mail”); message.setText(“TestMail […]

使用Commons-Email向Gmail发送电子邮件

Email email = new SimpleEmail(); String authuser = “……@gmail.com”; String authpwd = “*******”; // Very Important, Don’t use email.setAuthentication() email.setSmtpPort(465); email.setAuthenticator(new DefaultAuthenticator(authuser, authpwd)); email.setDebug(true); // true if you want to debug email.setHostName(“smtp.gmail.com”); email.getMailSession().getProperties().put(“mail.smtp.auth”, “true”); email.getMailSession().getProperties().put(“mail.debug”, “true”); email.getMailSession().getProperties().put(“mail.smtp.port”, “465”); email.getMailSession().getProperties().put(“mail.smtp.socketFactory.port”, “465”); email.getMailSession().getProperties().put(“mail.smtp.socketFactory.class”, “javax.net.ssl.SSLSocketFactory”); email.getMailSession().getProperties().put(“mail.smtp.socketFactory.fallback”, “false”); email.getMailSession().getProperties().put(“mail.smtp.starttls.enable”, “true”); email.setFrom(“……..@gmail.com”, “SenderName”); email.setSubject(“TestMail”); email.setMsg(“This is a test mail?”); email.addTo(“………….@gmail.com”, […]

如何在spring MVC web应用程序中确认电子邮件addrees

我正在注册用户的电子邮件地址。 但我想向用户发送一个确认链接,如果他们点击,那么他们的电子邮件地址得到确认 I am using java spring MVC hibernate mysql

如何从Java发送html电子邮件到Outlook

我正在尝试使用JavaMail以html格式发送电子邮件,但它似乎总是只在Outlook中显示为文本电子邮件。 这是我的代码: try { Properties props = System.getProperties(); props.put(“mail.smtp.host”, mailserver); props.put(“mail.smtp.from”, fromEmail); props.put(“mail.smtp.auth”, authentication); props.put(“mail.smtp.port”, port); Session session = Session.getDefaultInstance(props, null); // — Create a new message — MimeMessage message = new MimeMessage(session); // — Set the FROM and TO fields — message.setFrom(new InternetAddress(fromEmail, displayName)); message.setRecipients(Message.RecipientType.TO, InternetAddress.parse(to, false)); MimeMultipart content = new MimeMultipart(); MimeBodyPart text […]

如何使用纯文本和HTML文本发送邮件,以便每个邮件阅读器可以选择适合它的格式?

来自http://www.oracle.com/technetwork/java/faq-135477.html#sendmpa : 您将要发送MIME多部分/替代消息。 您构造此类消息的方式与构造多部分/混合消息的方式基本相同,使用使用新MimeMultipart(“alternative”)构造的MimeMultipart对象。 然后,将text / plain body部分作为multpart中的第一部分插入,并将text / html body部分作为multipart中的第二部分插入。 您需要自己构建plain和html部分以获得适当的内容。 有关此类消息的结构的详细信息,请参阅RFC2046。 有人可以给我看一些示例代码吗?

使用Apache Commons电子邮件库以Javaforms发送电子邮件

我正在使用Apache Commons电子邮件库发送电子邮件,但我无法通过GMail SMTP服务器发送它们。 任何人都可以提供与GMail SMTP服务器和其他服务器兼容的示例代码吗? 我使用以下代码不起作用: String[] recipients = {“receiver@gmail.com”}; SimpleEmail email = new SimpleEmail(); email.setHostName(“smtp.gmail.com”); email.setAuthentication(“sender@gmail.com”, “mypasswd”); email.setDebug(true); email.setSmtpPort(465); for (int i = 0; i < recipients.length; i++) { email.addTo(recipients[i]); } email.setFrom("sender@gmail.com", "Me"); email.setSubject("Test message"); email.setMsg("This is a simple test of commons-email"); email.send();

如何发送倾城报告的电子邮件?

我正在尝试使用selenium发送一个由框架生成的倾城报告的电子邮件。 我已阅读文档但无法找到有关如何发送电子邮件的任何答案。 任何人都可以指出我正确的方向。 谢谢,Sudheer

使用gmail smtp服务器和javamail在java中发送无需身份validation的电子邮件

我使用Javamail api和gmail smtp服务器在java中发送邮件而不提供密码。 我使用下面的代码。 这里我使用的是javax.mail jar文件 Properties props= new Properties(); props.put(“mail.smtp.host”, “smtp.gmail.com”); props.put(“mail.smtp.port”, 587); props.put(“mail.transport.protocal”, “smtps”); //Put below to false, if no https is needed props.put(“mail.smtp.STARTTLS.enable”, “false”); props.put(“mail.smtp.auth”, “false”); Session session = Session.getInstance(props); 我收到以下错误 Must issue a STARTTLS command first. b4sm3005855pdh.2 – gsmtp 实现代码有什么问题吗? 是否可以在没有密码的情况下实施? 请任何人帮助我