在上一篇中简单的实现了一个发送邮件功能的程序,今天用配置文件的方式来实现,大致思路一致,示例代码如下:
package com.javamail.test.demo;
import java.io.IOException;
import java.io.InputStream;
import java.util.Date;
import java.util.Properties;
import javax.mail.Authenticator;
import javax.mail.BodyPart;
import javax.mail.Message;
import javax.mail.MessagingException;
import javax.mail.Multipart;
import javax.mail.PasswordAuthentication;
import javax.mail.Transport;
import javax.mail.internet.AddressException;
import javax.mail.internet.InternetAddress;
import javax.mail.internet.MimeBodyPart;
import javax.mail.internet.MimeMessage;
import javax.mail.internet.MimeMultipart;
public class EmailUtil {
/**
* 发送邮件
* @param to
* 收信人
* @param subject
* 邮件主题
* @param content
* 邮件内容
* @throws IOException
* @throws AddressException
* @throws MessagingException
*/
public static void