差異處
這裏顯示兩個版本的差異處。
下次修改 | 前次修改 | ||
java:subethamail:a_simple_way_to_test_mail_sender [2016/08/25 17:36] tony 建立 |
java:subethamail:a_simple_way_to_test_mail_sender [2023/06/25 09:48] (目前版本) |
||
---|---|---|---|
行 1: | 行 1: | ||
{{tag>java}} | {{tag>java}} | ||
====== subethamail - a simple way to test mail sender ====== | ====== subethamail - a simple way to test mail sender ====== | ||
+ | ===== Problem ===== | ||
+ | 為了要驗證程式所寄出的人或訊息是否正確,我們可以寫一些mock程式去攔截收到的內容;也可以透過java mail去接收者的信箱中把內容撈出來比對。這些方法寫起來會比較花時間,如果能透過既有的mail server,可能就會容易多了。 | ||
===== How to? ===== | ===== How to? ===== | ||
+ | 原先Albert有找到一套叫[[https://nilhcem.github.io/FakeSMTP/|FakeSMTP]]的library,經過試驗發現它並不容易被拿進來寫UnitTest。因此直接使用它所相依的library subethamail,非常簡單就可以讓你去確認寄送者、接收者與信件內容: | ||
<code java> | <code java> | ||
private SMTPServer server; | private SMTPServer server; | ||
行 55: | 行 58: | ||
} | } | ||
</code> | </code> | ||
+ | ===== Reference ===== | ||
+ | * [[https://github.com/voodoodyne/subethasmtp|subethasmtp]] | ||
+ | * [[https://nilhcem.github.io/FakeSMTP/|FakeSMTP]] | ||
+ | |||
+ | ===== ===== | ||
+ | ---- | ||
+ | \\ | ||
+ | ~~DISQUS~~ | ||