LoginSignup
0
1

More than 3 years have passed since last update.

【Rails6 + ActionMailbox】ActionMailboxで受けとったGmailのプレーンテキスト抜き出した方

Posted at

課題

ActionMailboxで受けとったGmailは簡易版か否かでプレーンテキストの抜き出し方が違う。
恐らく他のメーラーもどちらかに該当する。。。。はず。

結論

プレーンテキストのそれぞれ抜き出し方。
Gmail簡易版 -> mail.body.decoded
Gmail現行版 -> mail.text_part.body.decoded

plain_text抜き出し例
def plain_text
  mail.text_part.nil? ? mail.body.decoded : mail.text_part.body.decoded
end

最初 gem 'sanitize' でも必要かと思って焦りました。
常識の範囲の知見なのに思いの外つまづいた。

0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1