Я пытаюсь использовать почту Java. это хорошо работает для Gmail, но когда я пытаюсь отправить через Yahoo или Hot Mail, он показывает
com.sun.mail.smtp.SMTPSendFailedException: 553 From address not verified
Я использовал
mailHost = "smtp.mail.yahoo.com";
и port = 465"
может любой орган подсказать мне как решить эту проблему Заранее спасибо.
здесь я отправляю код
public MailSender(String userId, String password)
{
this.userId = userId;
this.password = password;
Properties properties = new Properties();
properties.setProperty("mail.transport.protocol", "smtp");
properties.setProperty("mail.host", mailHost);
properties.put("mail.smtp.auth", "true");
properties.put("mail.smtp.port", "465");
properties.put("mail.smtp.socketFactory.class", "javax.net.ssl.SSLSocketFactory");
properties.put("mail.smtp.socketFactory.fallback", "false");
properties.setProperty("mail.smtp.quitwait", "false");
session = Session.getDefaultInstance(properties, this);
}
protected PasswordAuthentication getPasswordAuthentication()
{
return new PasswordAuthentication(userId, password);
}
public synchronized void sendMail(String subject, String body, String sender, String reciever) throws AddressException, MessagingException
{
MimeMessage mimeMessage = new MimeMessage(session);
DataHandler dataHandler = new DataHandler(new ByteArrayDataSource(body.getBytes(), "text/plain"));
mimeMessage.setSender(new InternetAddress(sender));
mimeMessage.setSubject(subject);
mimeMessage.setDataHandler(dataHandler);
if(reciever.indexOf(",")>0)
{
mimeMessage.setRecipients(Message.RecipientType.TO, InternetAddress.parse(reciever));
}
else
{
mimeMessage.setRecipient(Message.RecipientType.TO, new InternetAddress(reciever));
}
Transport.send(mimeMessage);
}