java - 无法从java程序: Unable to relay for abc@wipro. com发送电子邮件

标签 java email jakarta-mail

我正在尝试使用这篇文章 Java Point Post 使用 java 程序发送电子邮件。

import java.util.Properties;  
import javax.mail.*;  
import javax.mail.internet.*;  

public class SendMailBySite {  
 public static void main(String[] args) {  

  String host="IPADDRESS";  
  final String user="abc@wipro.com";//change accordingly  
  final String password="xxx";//change accordingly  

  String to="abc@wipro.com";//change accordingly  

   //Get the session object  
   Properties props = new Properties();  
   props.put("mail.smtp.host",host);  
   props.put("mail.smtp.auth", "true");  

   Session session = Session.getDefaultInstance(props,  
    new javax.mail.Authenticator() {  
      protected PasswordAuthentication getPasswordAuthentication() {  
    return new PasswordAuthentication(user,password);  
      }  
    });  

   //Compose the message  
    try {  
     MimeMessage message = new MimeMessage(session);  
     message.setFrom(new InternetAddress(user));  
     message.addRecipient(Message.RecipientType.TO,new InternetAddress

(to));  
     message.setSubject("javatpoint");  
     message.setText("This is simple program of sending email using 

JavaMail API");  

    //send the message  
     Transport.send(message);  

     System.out.println("message sent successfully...");  

     } catch (MessagingException e) {e.printStackTrace();}  
 }  
}  

我已正确输入 IpAddress,并且我的邮件 ID 和密码均正确。但是当我尝试运行这个程序时遇到一些异常。

java SendEmail
javax.mail.SendFailedException: Sending failed;
  nested exception is:
        class javax.mail.SendFailedException: Invalid Addresses;
  nested exception is:
        class javax.mail.SendFailedException: 550 5.7.1 Unable to relay for abc@wipro.com

        at javax.mail.Transport.send0(Transport.java:218)
        at javax.mail.Transport.send(Transport.java:80)
        at SendEmail.main(SendEmail.java:27)

请帮忙。提前致谢。

最佳答案

javax.mail.SendFailedException:550无法中继我的地址

This is not a JavaMail problem. This is an error reply from your SMTP mail server. It indicates that your mail server is not configured to allow you to send mail through it

Source

尝试更改 smtp 主机(例如 google)。另请检查 send email via google SMTP .

关于java - 无法从java程序: Unable to relay for abc@wipro. com发送电子邮件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28957056/

相关文章:

java - 使用哪个连接操作将多个表与 JPA/SQL 查询组合起来?

java - 收件人较多时无法发送电子邮件

java - 如何将 MimeMultipart 添加到另一个 MimeMultipart?

Javax.mail 对邮件收件箱文件夹中的邮件数量给出错误(更大)的计数

android - 使用 javamail 连接到 SMTP 时出错

java - 如何在 Eclipse 中使用 Lombok 生成复杂 json 的 pojo

java - 有没有办法使用java流来比较两个字符串?

java - 在 tcp 连接中... Java(数据包)

Python:将 .txt 附加到电子邮件中

php imap 检查邮件是否有附件