我正在使用 XAMPP 在 tomcat 中部署我的 java 应用程序,还使用水银邮件发送电子邮件。现在我只是用一个使用 java 邮件 API 和水银电子邮件的小型 java 程序来测试我的应用程序。我已经在 Mercury 中完成了必要的配置来设置 localhost。我的程序运行成功,没有任何错误。Mercury 日志文件也没有说明任何错误。
T 20130411 044359 51663963 Connection from 127.0.0.1
T 20130411 044359 51663963 EHLO 10.226.44.101
T 20130411 044359 51663963 MAIL FROM:<promil@localhost.com>
T 20130411 044359 51663963 RCPT TO:<*****@gmail.com>
T 20130411 044359 51663963 DATA
T 20130411 044359 51663963 DATA - 22 lines, 689 bytes.
T 20130411 044359 51663963 QUIT
T 20130411 044359 51663963 Connection closed with 127.0.0.1, 0 sec. elapsed.
这也是我的java文件....
公共静态无效主要(字符串[]参数){
// Recipient's email ID needs to be mentioned.
String to = "****@gmail.com";
// Sender's email ID needs to be mentioned
String from = "promil@localhost.com";
// Assuming you are sending email from localhost
String host = "localhost";
String password = "****";
// Get system properties
Properties properties = System.getProperties();
// Setup mail server
properties.setProperty("mail.smtp.host", host);
// Setup mail server
properties.setProperty("mail.smtp.password", password);
// Get the default Session object.
Session session = Session.getDefaultInstance(properties);
try{
// Create a default MimeMessage object.
MimeMessage message = new MimeMessage(session);
// Set From: header field of the header.
message.setFrom(new InternetAddress(from));
// Set To: header field of the header.
message.addRecipient(Message.RecipientType.TO,
new InternetAddress(to));
// Set Subject: header field
message.setSubject("This is the Subject Line!");
// Create the message part
BodyPart messageBodyPart = new MimeBodyPart();
// Fill the message
messageBodyPart.setText("This is message body");
// Create a multipar message
Multipart multipart = new MimeMultipart();
// Set text message part
multipart.addBodyPart(messageBodyPart);
// Part two is attachment
messageBodyPart = new MimeBodyPart();
String filename = "C:/Users/toshiba/Desktop/file.txt";
DataSource source = new FileDataSource(filename);
messageBodyPart.setDataHandler(new DataHandler(source));
messageBodyPart.setFileName(filename);
multipart.addBodyPart(messageBodyPart);
// Send the complete message parts
message.setContent(multipart );
// Send message
Transport.send(message);
System.out.println("Sent message successfully....");
}catch (MessagingException mex) {
mex.printStackTrace();
}
我对此一无所知......我的 Mercury 核心进程还说它有 4 个待处理的即将离职的工作......???