我写了一个从java(javamail/jaf)发送简单邮件的代码。运行该程序后,我收到一封来自google的电子邮件,表明我的帐户正被不安全的设备/应用程序访问。然后我不得不更改我的gmail帐户的设置以允许登录“不太安全的应用程序”选项。然后我收到了来自程序的电子邮件。
我需要在不更改选项的情况下发送电子邮件,允许在我的帐户中使用“不太安全的应用程序”选项。请帮忙。
我的代码是:
import java.util.Properties;
import javax.mail.Message;
import javax.mail.MessagingException;
import javax.mail.PasswordAuthentication;
import javax.mail.Session;
import javax.mail.Transport;
import javax.mail.internet.InternetAddress;
import javax.mail.internet.MimeMessage;
public class SendMailSSL {
public static void main(String[] args) {
Properties props = new Properties();
props.put("mail.smtp.host", "smtp.gmail.com");
props.put("mail.smtp.socketFactory.port", "465");
props.put("mail.smtp.socketFactory.class",
"javax.net.ssl.SSLSocketFactory");
props.put("mail.smtp.auth", "true");
props.put("mail.smtp.port", "465");
Session session = Session.getDefaultInstance(props,
new javax.mail.Authenticator() {
protected PasswordAuthentication getPasswordAuthentication() {
return new PasswordAuthentication("*****@gmail.com","*******");
}
});
try {
Message message = new MimeMessage(session);
message.setFrom(new InternetAddress("*****@gmail.com"));
message.setRecipients(Message.RecipientType.TO,
InternetAddress.parse("*****@gmail.com"));
message.setSubject("Testing Subject");
message.setText("Dear User," +
"\n\n No spam to my email, please!");
Transport.send(message);
System.out.println("Done");
} catch (MessagingException e) {
throw new RuntimeException(e);
}
}
}
Gmail避免这种情况的唯一方法是使用OAuth 2.0身份验证。您可以通过此链接阅读它。https://developers.google.com/gmail/xoauth2_protocol?hl=en
我正在尝试通过连接到LDAP使用Spring Security进行我的第一个演示。 我使用的Sping版本是:3.1.0.RELEASE 以下是我的security-integration.xml: 然而,每当我部署我的战争时,我都会遇到这个例外: HTTP状态500 - 类型异常报告 消息 描述服务器遇到一个内部错误(),该错误阻止它完成此请求。 例外情况 javax.servlet。Servl
我正在运行一个非常基本的Javamail程序来尝试发送电子邮件。这是带有main()的独立程序。一旦我让它工作,我计划在tomcat下运行的servlet中使用Javamail。 运行此程序时,我收到身份验证登录失败错误。我尝试了几种不同的属性设置,但都没有解决问题。 然后我在SO上找到一篇帖子,建议降低我谷歌账户的安全级别。当我降低安全设置时,身份验证成功。 当然,我立即回到了谷歌账户的更高安全
在我的Gmail A/C上,我从production server运行代码后收到了以下电子邮件 嗨, 最近有人使用您的密码尝试登录您的Google帐户mymailid@gmail.com。此人正在使用电子邮件、客户端或移动设备等应用程序。 2014年1月3日星期五13:56:08点钟UTC IP地址:xxx.xx.xx.xxx(abcd.net.)地点:美国宾夕法尼亚州费城 如果您无法识别此登录尝
我正在测试Spring Security中的登录方法。我想获得200的地位,但来了401。
问题内容: 尝试使用JavaMail中的NTLM连接到Exchange服务器。我可以连接到SMTP,但不能连接到IMAP。我还可以使用相同的主机/用户名/密码通过OS X Mail.app应用程序进行身份验证,帐户类型=“ IMAP”,端口143,ssl = false,authentication = NTLM,域名=“。 连接代码: 输出: 我尝试通过http://www.oracle.com
问题内容: 我收到错误 NOAUTH必需的身份验证 。我的laravel版本是5.3,我正在使用predis 1.1.1连接redis。 在etc / redis / redis.conf中,我有: 在.env文件中 在config / database.php中,我有: 我通过以下方式连接redis: 并像这样使用它: 因此,当我注释掉并将密码发送为null时,它可以工作,但在密码到位后却无法工