[英]How do I send mail from yahoo and others in android
我正在尝试使用Java邮件。 这适用于gmail,但当我尝试通过yahoo或热邮件发送时,它显示
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);
}
出现此错误消息的最可能原因是,您必须先登录到SMTP服务器,然后才能通过它发送任何消息。 或者,可能是因为您尝试从非Yahoo邮件地址发送邮件,或者是从不存在的地址发送邮件。
mailHost =“ smtp.mail.yahoo.com”;
和端口= 587试试这个
尝试以下设置:
Server: smtp.mail.yahoo.com
Port: 465
Security: SSL
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.