SendGridで簡単メール配信
サービスで利用するメール配信の仕組みをどうしようかなあと考えていたのですが、以前CoffeeMeetingのサービス構成でSendGridを使っていると書かれていたのを思い出したので実際に使ってみました。
SendGrid
Email Delivery. Simplified. SendGrid's cloud-based email infrastructure relieves businesses of the cost and complexity of maintaining custom email systems. SendGrid provides reliable delivery, scalability and real-time analytics along with flexible APIs that make custom integration a breeze.
HerokuのAddonsリストでフィーチャーされているのですが、検索してもあまり日本語の情報が出てこないあたり利用されているのかいないのかよく分からない感じでしたが、かなり簡単に扱えました。
まずはアカウントの登録
まずは、というか必要なのはこれだけ。
1. Sign upからアカウント作成
2. コンタクト情報を登録(メール配信を行うサイト情報など)
3. メール配信が可能になる(Congratulations! Your account has been provisioned. というメールが届く)
アプリケーション側の処理 (Rails)
SMTPの設定
environment.rbに設定を追加します。
ActionMailer::Base.smtp_settings = {
:user_name => "SendGridのユーザーネーム",
:password => "SendGridのログインパスワード",
:domain => "appstair.com",
:address => "smtp.sendgrid.net",
:port => 587,
:authentication => :plain,
:enable_starttls_auto => true
}
Mailerの作成
ファイルを1つ作るだけ。
app/mailer/notifier.rb
# -*- encoding: utf-8 -*-
class Notifier < ActionMailer::Base
default :from => "info@appstair.com"
def signup_email
mail( :to => "ntakuto@gmail.com", :subject => "登録ありがとうございます")
end
end
料金プラン
気になるプランはこんな感じ。まだその他の機能などほとんど見れていませんが、これなら使っても良いかなと思える値段設定でした。
| Free | 200件/日 | 無料 |
| Bronze | 4万件/月 | $9.95 |
| Silver | 10万件/月 | $79.95 |
Amazon SESも試そうかなと思ってたのですが、これでもう十分やっていけそうな感じです。何より、使ってみようかなと思って実際に使えるまでの敷居が低かったことと、すぐにその効果を実感できる作りになっているのはいいなあと思いました。
アプリでもサービスでも一緒ですが、それがどういう価値を提供しているのかが明確であり、使ってみてすぐにその価値を実感できる、というのはものすごく重要ですよね。

