You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session. You switched accounts on another tab or window. Reload to refresh your session. Dismiss alert
こんにちは、yamadaです。入社から1年半ほど経ちますが、初めての記事になります。 今回はRailsとSendGridでメール送信を行った時の手順をまとめようと思います。 Rails 5.2 SendGrid(V3 Mail Send API) sendgrid.comより APIキーの作成 まずはSendGridのAPIキーを作成します。作成方法は公式ドキュメントをご確認ください。 権限は使用目的に合わせて設定しましょう。単純なメール送信だけであれば「Mail Send」を「Full Access」にすればOKです。 APIキーを管理する - ドキュメント | SendGridより 実装 配信方法の切り替えを簡単にするため、delivery_methodを追加する形で対応しました。 参考: Action Mailerのdelivery_methodに独自の配信方法を追加する SendG
This is a post about how I had a bug in a background job that ended up sending huge emails to customers. Learn about how I found & debugged the issue, mitigated the problem, and then finally fixed the underlying causes. Previous title was “Sending Massive Emails Considered Harmful”. It was a quiet day in July when I got a message from SendGrid about a service I run, CodeTriage, which helps people
Quipper、日本オフィスができて半年以上達ち、このブログでも改めて色々発信してみようと思ってはいるのだけど、一度間が空いてしまったブログの再開はなかなか難しい(本人以外誰も気にしていない現実を知りつつ)。この状況を打破するために、軽いのをまず書いてみる。本当はQuipperの開発について色々書きたいんだけど、それはまた次回。 最近出会った mailtrap.io というサービスがWebシステム開発にとてもいい感じなので紹介してみる。 メール送信は、ある程度テストを自動化したとしても、繰り返し、手で実行して目で確認することも多い。テストするときは、送信先アドレスを自分にして、送信して、自分のメールボックスを開いて確認する、とか。めんどくさい。何か問題を発見したら、関係者にメールをフォワード、とかもめんどくさい。ステージング環境では実際に送らずに、ログに出すという方法もあるけど、これだと、
たまたま Rails の ActionMailer について調べてみる機会がありましたので、そこに見られた Observer について書きたいと思います。 ご存知のように、メールの送信というものは失敗する可能性があります。ですので、できうるかぎりメールはユーザに届けたい!という場合は、再送の手間をかけなければいけないこともあるわけですが、そうした際に必要になってくるのは、そう、送信ログです。ActionMailer では簡単に送信ログがとれますので、今回はそれについて書いてみます。 たとえば次のようなメールアクションがあったとします。 class FooMailer < ActionMailer::Base def foo(recipient_email_address) mail(to: recipient_email_address, body: 'foo') end end
読み進めると、unit tests および functional tests で Mailer をテストすると説明してあります。 unit tests: 単体でテストを行い、入力値と出力値を比較して確認する。上記の 1, 2 の項目をテスト。 functional tests: Mailer を使うコントローラーやモデルが Mailer を正しく操作しているかテストする。正しいEメールが正しい時間に送られたかをテストする。上記 3 の項目をテスト。 Unit Testing ActionMailer::Base.deliveries に送信済みのメール(メールのオブジェクト)が配列で格納されます。 Action Mailer Basics — Ruby on Rails Guides Unit テストでは次を確認する。 ・Eメール を deliver(送信)した後に、ActionMaile
Almost every application I ever worked on had some requirement to send emails. Whenever I need to implement sending emails (using Action Mailer), I also implement a background job for it. Since version 4.2, Rails has built-in support for executing background jobs using Active Job. Every time I need to start setting up Active Job for email sending, I find myself looking up the required syntax and s
Fragment cache helps in caching parts of the view instead of caching the entire view. Fragment caching is used when different parts of the view need to be cached and expired separately. Before Rails 5, fragment caching was supported only in Action View templates. Rails 5 provides fragment caching in Action Mailer views . To use this feature, we need to configure our application as follows. This co
まえがき Herokuのアドオンとして人気のある無料から使えるメール送信サービスである『SendGrid』を使ってRailsアプリからメールを送信をしてみようというのが今回のテーマ。 今回はHerokuではなくて、ローカル開発環境でRailsアプリからメールを送信してみる。 Herokuではアドオンを使ってSendgridを利用できるが、今回のやり方でもメール送信はできるはず 開発環境 Ruby 2.1.0 Rails 4.0.2 せっかくのサンプルアプリ開発なのでRuby、Railsともに最新のバージョンでやってみることにした。 SendGridについて https://sendgrid.kke.co.jp SendGridはクラウドベースのメール送信サービスでSMTPやWEBAPIを利用して、メール送信ができます。 無料プランでは1日200通までメールを送信することができ、有料プランだ
1 はじめに Action Mailerを使うと、アプリケーションのメーラークラスやビューでメールを送信できます。メーラーの動作はコントローラときわめて似通っています。メーラーはActionMailer::Baseを継承し、app/mailersに配置され、app/viewsにあるビューと結び付けられます。 メーラーには以下が含まれます。 アクション、および関連付けられたビュー(app/viewsに現れる) インスタンス変数(ビューでアクセス可能) レイアウトやパーシャルを利用可能にする機能 paramsハッシュにアクセス可能にする機能 2 メールを送信する このセクションでは、メーラーとビューの作成方法を手順を追って説明します。 2.1 メーラー生成の全手順 2.1.1 メーラーを作成する $ bin/rails generate mailer User create app/maile
rails railsアプリからメールを送信することは簡単にできますが、開発中に送信メールを確認したいときはどうするでしょうか。 今回はrailsアプリ開発中にメールを確認する方法を紹介します。 今回はメール確認の例として、deviseを用いてメール認証が必要なユーザー登録の仕組みを用意します。 deviseインストール railsアプリケーションがすでに初期化されていたとして、Gemfileにdeviseを追加し、インストールを行います。 bundle exec rails generate devise:install bundle exec rails generate devise user bundle exec rails generate devise:views users カスタマイズ用のviewを生成し Devise.setup do |config| config.s
送信者をメールアドレスでなく名前で表示する 送信者名がnoreply@yoursite.comみたいなメールアドレスではなく、名前を表示させるようにしたいですよね。 そんな時はfromをこんな風に設定。
Action Mailer Base Action Mailer allows you to send email from your application using a mailer model and views. Mailer Models To use Action Mailer, you need to create a mailer model. $ bin/rails generate mailer Notifier The generated model inherits from ApplicationMailer which in turn inherits from ActionMailer::Base. A mailer model defines methods used to generate an email message. In these metho
リリース、障害情報などのサービスのお知らせ
最新の人気エントリーの配信
処理を実行中です
j次のブックマーク
k前のブックマーク
lあとで読む
eコメント一覧を開く
oページを開く