用 Java 在 AWS 调用邮件接口:
可能需要用到的 jar 包,如图:
import javax.mail.Session;
import javax.mail.Transport;
import javax.mail.internet.InternetAddress;
import javax.mail.internet.MimeMessage;
import java.util.Properties;
public class SendEmail {
public void sendEmailBySmtp(MessageVo emailSentRecord) throws Exception {
Properties props = System.getProperties();
props.put("mail.transport.protocol", "smtp");
props.put("mail.smtp.port", 587);
props.put("mail.smtp.starttls.enable", "true");
props.put("mail.smtp.auth", "true");
Session session = Session.getDefaultInstance(props);
MimeMessage msg = new MimeMessage(session);
String smtpUserName = "xxxxxxxx"; // 带有权限的 AWS 帐号
String smtpUse