mail_stdin.rb 801 B

1234567891011121314151617181920212223242526272829303132
  1. # Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
  2. class Channel::Driver::MailStdin < Channel::EmailParser
  3. =begin
  4. process emails from STDIN
  5. cat /path/to/mail.eml | rails r 'Channel::Driver::MailStdin.new'
  6. e. g.
  7. cat test/data/mail/mail001.box | rails r 'Channel::Driver::MailStdin.new'
  8. e. g. if you want to trust on mail headers
  9. cat test/data/mail/mail001.box | rails r 'Channel::Driver::MailStdin.new(trusted: true)'
  10. e. g. if you want to process this mail by using a certain inbound channel
  11. cat test/data/mail/mail001.box | rails r 'Channel::Driver::MailStdin.new(Channel.find(14))'
  12. =end
  13. def initialize(params = {}) # rubocop:disable Lint/MissingSuper
  14. Rails.logger.info 'read main from STDIN'
  15. msg = ARGF.read
  16. process(params, msg)
  17. end
  18. end