- iOS/Objective-C 元类和类别
- objective-c - -1001 错误,当 NSURLSession 通过 httpproxy 和/etc/hosts
- java - 使用网络类获取 url 地址
- ios - 推送通知中不播放声音
我正在使用以下代码但收到错误消息 -运行:
javax.mail.SendFailedException: Invalid Addresses; nested exception is: com.sun.mail.smtp.SMTPAddressFailedException: 530 5.7.0 : Recipient address rejected: Authentication Required at com.sun.mail.smtp.SMTPTransport.rcptTo(SMTPTransport.java:1607) at com.sun.mail.smtp.SMTPTransport.sendMessage(SMTPTransport.java:887) at javax.mail.Transport.send0(Transport.java:191) at javax.mail.Transport.send(Transport.java:120) at MailClient.sendMail(MailClient.java:55) at MailClient.main(MailClient.java:94)Caused by: com.sun.mail.smtp.SMTPAddressFailedException: 530 5.7.0 : Recipient address rejected: Authentication Required at com.sun.mail.smtp.SMTPTransport.rcptTo(SMTPTransport.java:1505) ... 5 more
/**
*
* @author sachin
*/
import javax.mail.*;
import javax.mail.internet.*;
import javax.activation.*;
import java.io.*;
import java.util.Properties;
public class MailClient
{
public void sendMail(String mailServer, String from, String to,
String subject, String messageBody
) throws MessagingException, AddressException
{
// Setup mail server
Properties props = System.getProperties();
props.put("mail.smtp.host", mailServer);
// Get a mail session
Session session = Session.getDefaultInstance(props, null);
// Define a new mail message
Message message = new MimeMessage(session);
message.setFrom(new InternetAddress(from));
message.addRecipient(Message.RecipientType.TO, new InternetAddress(to));
message.setSubject(subject);
// Create a message part to represent the body text
BodyPart messageBodyPart = new MimeBodyPart();
messageBodyPart.setText(messageBody);
//use a MimeMultipart as we need to handle the file attachments
Multipart multipart = new MimeMultipart();
//add the message body to the mime message
multipart.addBodyPart(messageBodyPart);
// add any file attachments to the message
// addAtachments(attachments, multipart);
// Put all message parts in the message
message.setContent(multipart);
// Send the message
Transport.send(message);
}
protected void addAtachments(String[] attachments, Multipart multipart)
throws MessagingException, AddressException
{
for(int i = 0; i<= attachments.length -1; i++)
{
String filename = attachments[i];
MimeBodyPart attachmentBodyPart = new MimeBodyPart();
//use a JAF FileDataSource as it does MIME type detection
DataSource source = new FileDataSource(filename);
attachmentBodyPart.setDataHandler(new DataHandler(source));
//assume that the filename you want to send is the same as the
//actual file name - could alter this to remove the file path
attachmentBodyPart.setFileName(filename);
//add the attachment
multipart.addBodyPart(attachmentBodyPart);
}
}
public static void main(String[] args)
{
try
{
MailClient client = new MailClient();
String server="smtp.bsgroup.in";
String from="sachinsingh@bsgroup.in";
String to = "sachinsingh@bsgroup.in";
String subject="Test Mail";
String message="Testing Mail";
// String[] filenames =
//{"c:\somefile.txt"};
client.sendMail(server,from,to,subject,message);
}
catch(Exception e)
{
e.printStackTrace(System.out);
}
}
}
最佳答案
您收到的错误消息告诉您,您连接到的 SMTP 服务器需要身份验证才能使用它发送电子邮件,而您还没有提供任何身份验证详细信息。
参见 here (Internet Archive)有关在 SMTP 服务器需要身份验证时如何发送电子邮件的示例。
关于java - com.sun.mail.smtp.SMTPAddressFailedException : Recipient address rejected: Authentication Required,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3254804/
我想在 DNN 模块中完成注册过程后发送电子邮件。当我搜索时,我发现 dnn 中有一个内置的邮件类。但它包含两个方法 - SendEmail 和 SendMail。这两者有什么区别?在这种情况下我必须
我有一个非常特殊的要求 我正在使用 Java Mail API 访问用户的收件箱。可以说是投诉服务信箱。用户通过向该地址发送电子邮件来注册投诉。我从收件箱中提取每封电子邮件并创建一个新的投诉。我的问题
我正在使用64位MS SQL Server 2008 R2 SP2 Express版。 我没有访问数据库邮件设置向导的权限,但是Binn目录包含DatabaseMail.exe(v10.50.1660
我正在为使用 Mail::queue 函数发送电子邮件的代码编写单元测试,如文档中的代码:https://laravel.com/docs/5.4/mocking#mail-fake 我的测试: /*
我试图使用 java 邮件 API 阅读我的 gmail 帐户中的邮件。这是代码: import java.util.*; import java.io.*; import java.awt.*; i
我已经看到关于此主题的数千个类似问题。可以肯定的是,我知道 SO 中的“标记为重复问题”。 但是,从 PHP mail() 函数获取雅虎收件箱电子邮件,简单来说,如何或必须做什么仍然不清楚。 在 Ya
我正在尝试从 php 向 gmail 帐户发送电子邮件。我的笔记本电脑上有以下设置: Windows 8 Internet connection XAMPP 1.7.4, PHP Version 5.
使用过时的 System.Web.Mail 发送电子邮件工作正常,这是代码片段: Public Shared Sub send(ByVal recipent As String, ByVal fro
有没有办法从 Java Mail API 中获取邮件是否被标记为重要?我正在使用 Gmail 帐户进行连接。提前致谢。 最佳答案 不同的邮件程序使用不同的方式来表明邮件“重要”。有些使用 X-Prio
我正在编写一个 PHP 邮件函数,一些示例有 @mail(...),而其他示例只有 mail(...)。 有什么区别,最好使用哪个? 干杯 最佳答案 @ 抑制所有警告/错误,mail() 函数可能会抛
我一直在开发一个连接到 Yahoo 邮件的 Java 应用程序,使用户能够通过他们的 Yahoo 电子邮件进行搜索。 最近,Yahoo 突然(仅提前 5 周通知)停止了我们正在使用并且运行良好的 Ya
我想发送邮件为用户重置密码,如果他忘记了密码,我会收到此错误: org.springframework.mail.MailSendException: Mail server connection f
所以,我的问题如下:我有一个用 Java 编写的邮件客户端,在使用 POP3 检查邮件后,无法通过 SMTP 发送邮件。 我捕获的异常表明传输协议(protocol) = null。 代码工作正常,因
我正在尝试使用 ruby mail gem 检索电子邮件,在示例中它说 Mail.last将检索最后一封未读电子邮件 https://github.com/mikel/mail#getting-e
在我的系统中,我应该在查看列表后发送通知邮件我正在使用 DNN 有我使用的代码 private void SendEmailNotification() { DotNetNuk
我创建了一个.sh脚本,并将结果记录在一个文件中,执行后我会尝试将文件内容作为mail正文发送。 这是我运行的命令: sh update.sh >> update.$(date +"%Y-%m-%d:
我使用 AE.NET.Mail 来阅读我的电子邮件正文。 但是那些尸体都是空的! 我的代码如下: // Connect to the IMAP server. The 'true' param
关闭。这个问题不符合Stack Overflow guidelines .它目前不接受答案。 这个问题似乎不是关于 a specific programming problem, a softwar
我在尝试发送带有文件附件的电子邮件时遇到错误: javax.mail.internet.ParseException: Expected '/', got files at javax.mai
我在IntelliJ IDEA中导入了一个maven项目后,pom.xml文件有两个错误: "Failed to read artifact descriptor for javax.mail:mai
我是一名优秀的程序员,十分优秀!