jsだけ使ってメールが送れる世の中らしい
便利ですね
- MailChimpがMandrillというメール専門のBaaSのようなことをやってる
- Transactional Email from MailChimp - Mandrill
- xhrでpostするとメールが送れる
- via:
- 12,000通/月まで無料
- Mandrill - Transactional Email from MailChimp
- mailchimpのようにダッシュボードで、開封チェックとか送る側が知りたい情報が知れる機能が使える
- htmlメールとか、画像埋込とか、添付ファイルとかメールに欲しいものもひと通りできる
- Messages API | Mandrill
やってみた
- mandrillでサインアップして、api keyもらう手順
- 割愛
- 今見てるページのタイトルを件名、body要素を本文にしたhtmlメールを送る
# 送るデータ作って data = key: "ここにapikey" message: from_email: "差出人メアド" to: [ email: "ここに宛先メアド" name: "宛先人の名前" type: "to" ] autotext: "true" subject: document.title html: document.body.innerHTML # ポスト xhr = new XMLHttpRequest() xhr.open "POST","https://mandrillapp.com/api/1.0/messages/send.json",true xhr.setRequestHeader "Content-Type","application/json" xhr.send JSON.stringify(data)
使い途
- 魚拓のように使ってる「あとで読む」が使えないページがある
- 代わりに、mandrill使ってメール飛ばすブックマークレットに使ってる
githubとか、あとで読むに飛ばせないページが増えてきた
- chromeだとこんなエラーがでる
Refused to load the script 'http://atode.....' because it violates the following Content Security Policy directive: "script-src 'self' https://github.global.ssl.fastly.net https://ssl.google-analytics.com https://collector-cdn.github.com https://analytics.githubapp.com https://embed.github.com https://raw.github.com".
でもpocketとかifftとか手を出すのがちょっと面倒