使用SpringBoot傳送郵件

2021-10-10 06:05:41 字數 638 閱讀 5289

在pom中引入用於傳送郵件的starter

>

>

org.springframework.bootgroupid

>

>

spring-boot-starter-mailartifactid

>

dependency

>

spring

:mail

:#郵箱的賬號

username

: *********[email protected]

#郵箱的授權碼,需要開啟pop3/smtp/imap服務才能正常傳送郵件,

password

: ************

#郵箱的伺服器位址 我這裡是163郵箱所以用的是163的郵箱位址

host

: smtp.163.com

編寫郵箱傳送**

//將這個類交給spring管理

@component

public

class

testmailsend

catch

(exception e)

}}

Springboot傳送美觀的HTML郵件

上篇文章我們知道了如何利用springboot傳送乙個基本的html郵件,現在問題來了不美觀怎麼辦呢?我們可以自己寫乙個html模板然後利用thymeleaf載入資料。建立mailtemplate.ftl 作為郵件模版 只需要修改我們上次的imailserviceimpl其中傳送html郵件的方法 ...

thinkPHP PHPMailer 傳送郵件

二 在thinkphp的配置檔案config.php中寫以下 郵件傳送配置 mail host smtp.163.com smtp伺服器的名稱 mail host smtp.exmail.qq.com 郵箱是qq mail smtpauth true,啟用smtp認證 mail username 1...

thinkphp phpmailer傳送郵件

1.在function.php中新增 郵件傳送函式 param address 郵件收件人位址 param titlle 郵件標題 param content 郵件內容 param attachment 附件 function sendmail addressee,title,content,att...