使用的maven依賴(lài):
<dependency>
<groupId>com.sun.mail</groupId>
<artifactId>javax.mail</artifactId>
<version>1.4.7</version>
</dependency>
配置文件mail.properties如下:
# 郵箱配置
email.username=your-email@example.com
email.password=your-email-password
email.server=smtp.example.com
email.auth=true
email.port=465
在Foxmail的配置如下:
文章來(lái)源:http://www.zghlxwxcb.cn/news/detail-858342.html
代碼如下:文章來(lái)源地址http://www.zghlxwxcb.cn/news/detail-858342.html
import org.springframework.stereotype.Component;
import javax.activation.DataHandler;
import javax.mail.*;
import javax.mail.internet.*;
import javax.mail.util.ByteArrayDataSource;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStre
到了這里,關(guān)于Java發(fā)送郵件 啟用SSL的文章就介紹完了。如果您還想了解更多內(nèi)容,請(qǐng)?jiān)谟疑辖撬阉鱐OY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!