错误:
DEBUG:setDebug:JavaMail版本1.4ea DEBUG:getProvider()返回javax。邮政提供商[TRANSPORT,smtp,com.sun.mail.smtp.SMTPTransport,sun Microsystems,Inc]调试smtp:useEhlo true,useAuth true调试smtp:尝试连接到主机“smtp.mail.yahoo.com”,端口465,isSSL false javax。邮政MessaginException:无法连接到SMTP主机:SMTP。邮政雅虎。com,端口:465;嵌套的例外是:java。网ConnectException:连接超时:connect 253******@yahoo。com test******@yahoo。亲爱的
at com.sun.mail.smtp.SMTPTransport.openServer(SMTPTransport.java:1282)
at com.sun.mail.smtp.SMTPTransport.protocolConnect(SMTPTransport.java:370)
at javax.mail.Service.connect(Service.java:275)
at javax.mail.Service.connect(Service.java:156)
at SendEmail.sendFromYahoo(SendEmail.java:137)
at SendEmail.main(SendEmail.java:50)
Caused by: java.net.ConnectException: Connection timed out: connect
at java.net.DualStackPlainSocketImpl.connect0(Native Method)
at java.net.DualStackPlainSocketImpl.socketConnect(DualStackPlainSocketImpl.java:79)
at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:339)
at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:200)
at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:182)
at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:172)
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
at java.net.Socket.connect(Socket.java:579)
at java.net.Socket.connect(Socket.java:528)
at com.sun.mail.util.SocketFetcher.createSocket(SocketFetcher.java:232)
at com.sun.mail.util.SocketFetcher.getSocket(SocketFetcher.java:189)
at com.sun.mail.smtp.SMTPTransport.openServer(SMTPTransport.java:1250)
... 5 more
我想在java中使用yahoo mail发送邮件我的代码是
Properties props = System.getProperties();
String host = "smtp.mail.yahoo.com";
props.put("mail.smtp.starttls.enable", "true");
props.put("mail.smtp.host", host);
props.put("mail.smtp.user", from);
props.put("mail.smtp.password", pass);
props.put("mail.smtp.ssl.enable", "true");
props.put("mail.smtp.port", "465");//587
props.put("mail.smtp.auth", "true");
Session session = Session.getDefaultInstance(props);
MimeMessage message = new MimeMessage(session);
session.setDebug(true);
try {
message.setFrom(new InternetAddress(from));
InternetAddress[] toAddress = new InternetAddress[to.length];
// To get the array of addresses
for( int i = 0; i < to.length; i++ ) {
toAddress[i] = new InternetAddress(to[i]);
}
for( int i = 0; i < toAddress.length; i++) {
message.addRecipient(Message.RecipientType.TO, toAddress[i]);
}
message.setSubject(subject);
message.setText(body);
Transport transport = session.getTransport("smtp");
transport.connect(host, from, pass);
transport.sendMessage(message, message.getAllRecipients());
transport.close();
System.out.println("Sent message successfully....");
}
catch (AddressException ae) {
ae.printStackTrace();
}
catch (MessagingException me) {
me.printStackTrace();
}
您应该能够使用以下程序发送电子邮件:
public class SendMail {
String host, port, emailid,username, password;
Properties props = System.getProperties();
Session l_session = null;
public SendMail() {
host = "smtp.mail.yahoo.com";
port = "465";
emailid = "...@yahoo.com";
username = "...";
password = "pwd";
emailSettings();
createSession();
sendMessage("...@yahoo.com", "xyz@gmail.com","Test subject","Test mail with some random text");
}
public void emailSettings() {
props.put("mail.smtp.host", host);
props.put("mail.smtp.auth", "true");
props.put("mail.debug", "false");
props.put("mail.smtp.port", port);
}
public void createSession() {
l_session = Session.getInstance(props,
new javax.mail.Authenticator() {
protected PasswordAuthentication getPasswordAuthentication() {
return new PasswordAuthentication(username, password);
}
});
l_session.setDebug(true);
}
public boolean sendMessage(String emailFromUser, String toEmail, String subject, String messageText) {
try {
MimeMessage message = new MimeMessage(l_session);
emailid = emailFromUser;
message.setFrom(new InternetAddress(this.emailid));
message.addRecipient(Message.RecipientType.TO, new InternetAddress(toEmail));
message.addRecipient(Message.RecipientType.BCC, new InternetAddress(toEmail));
message.setSubject(subject);
message.setContent(messageText, "text/html");
Transport.send(message);
System.out.println("An email has been sent");
} catch (MessagingException mex) {
mex.printStackTrace();
} catch (Exception e) {
e.printStackTrace();
}
return true;
}
}
希望这有帮助!
我使用下面提到的代码发送电子邮件。 我得到下面提到的错误。 通用域名格式。亚马逊。AmazonServiceException:我们计算的请求签名与您提供的签名不匹配。检查您的AWS秘密访问密钥和签名方法。有关详细信息,请参阅维修文档。此请求的规范字符串应为“POST”/ 主持人:电子邮件。美国东部1号。亚马逊。com用户代理:aws sdk java/1.9。0 Linux/3.19。0-25-
我试图通过节点邮件发送电子邮件,但无法发送电子邮件,并显示以下错误。 我使用的是nodemailer文档中所示的确切代码。 这是我正在使用的服务器端代码。 这在几天前运行良好,在其他邮件客户端和gmail上也运行良好,因此我认为这个问题可能与gmail帐户的任何安全设置有关。
我试图从域发送邮件,但得到一些错误。
我正在使用 jenkins docker image。我想将我的邮件配置给 jenkins,以便我可以收到有关所有构建的邮件。 我应该在docker-image中做什么更改,以便能够给自己发送邮件? 我收到此错误 我用来运行docker镜像的命令是: $docker run-u 0——名称myjenkins1-p 8081:8080-p 50001:50000-v jenkins_home:/va
我想用Java发送一封邮件,但使用我在http://www.tutorialspoint.com/Java/java_sending_email.htm找到的这篇泰文教程是行不通的。 这里是我的主要方法 我有以下错误: javax.mail.MessagingException:无法连接到SMTP主机:localhost,端口:25;嵌套异常为:java.net.connectException:
responseerror:禁止在d:\node-projects\ecom\node_modules@sendgrid\client\src\类\client.js:146:29在processTicksAndRejections(internal/process/task_queues.js:93:5){ 代码:403,response:{headers:{server:'nginx',dat