从brinkster托管帐户使用java发送邮件
我需要使用java从brinkster托管帐户发送电子邮件。我用这个代码从我的gmail帐户发送电子邮件,它工作得很好从brinkster托管帐户使用java发送邮件,java,email,smtp,Java,Email,Smtp,我需要使用java从brinkster托管帐户发送电子邮件。我用这个代码从我的gmail帐户发送电子邮件,它工作得很好 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
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("gmailuser", "password");
}
});
try {
Message message = new MimeMessage(session);
message.setFrom(new InternetAddress("gmailuser@gmail.com"));
message.setRecipients(Message.RecipientType.TO,
InternetAddress.parse("someone@gmail.com"));
message.setSubject("subject");
message.setText("text");
Transport.send(message);catch (MessagingException e) {
throw new RuntimeException(e);
}catch (MessagingException e) {
throw new RuntimeException(e);
}
现在,我需要从以下地址发送电子邮件:username@company.com.co
我有这个
Properties props = new Properties();
props.put("mail.smtp.host", "mymail.brinkster.com"); //<--changed this
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("username@company.com.co", "password"); //<--changed this
}
});
try {
Message message = new MimeMessage(session);
message.setFrom(new InternetAddress("username@company.com.co")); //<--changed this
message.setRecipients(Message.RecipientType.TO,
InternetAddress.parse("someone@gmail.com"));
message.setSubject("subject");
message.setText("text");
Transport.send(message);
} catch (MessagingException e) {
throw new RuntimeException(e);
}
Properties=newproperties();
put(“mail.smtp.host”、“mymail.brinkster.com”)// 我可以知道你得到的是什么类型的例外情况吗
每个主机都有不同的名称(mail.smtp.host),请确保您的主机名正确
在gmail中,无论你提供的地址是什么,它都不会显示为from address我试图连接到主机“mymail.brinkster.com”,端口465,isSSL false。然后我发现连接超时了。我不确定主机名应该是什么,我找不到。在哪里可以找到主机名@vikasramireddyhost名称必须由主机提供,不要假定为