SlideShare a Scribd company logo
1 of 21
Download to read offline
mail
16 5 29
self.about
• Toshio Maki(Twitter: @Kirika_K2)
• Hatena id:Kirika, Github: kirikak2
•
•
(MilterManager / Ruby / Rails)
•
(GitLab / Drone / CloudFoundry)
16 5 29
mail
• https://github.com/mikel/mail
• ActionMailer
•
mail
16 5 29
Context
• mail
•
•
•
• gem mail gem
16 5 29
Generate new mail
mail = Mail.new do
to "alice@example.com"
from "bob@example.com"
subject "Test mail"
body "This is a test mail"
end
puts mail.to_s
Date: Sun, 15 May 2016 14:10:34 +0900
From: bob@example.com
To: alice@example.com
Message-ID: <573804ca7b995_6788082dbf8745d3@gitorious.orz.cn.mail>
Subject:Test mail
Mime-Version: 1.0
Content-Type: text/plain;
charset=UTF-8
Content-Transfer-Encoding: 7bit
This is a test mail
16 5 29
Parse new mail
mail = Mail.new(File.read(‘/path/to/mail’))
puts mail.to_s
Date: Sun, 15 May 2016 14:10:34 +0900
From: bob@example.com
To: alice@example.com
Message-ID:
<573804ca7b995_6788082dbf8745d3@gitorious.orz.cn.mail>
Subject:Test mail
Mime-Version: 1.0
Content-Type: text/plain;
charset=UTF-8
Content-Transfer-Encoding: 7bit
This is a test mail
16 5 29
mail
•
• Notes / Outlook RFC
• Syntax
•
•
• uuencode okkez PR
•
16 5 29
mail
maildata = File.read("japanese_shift_jis.eml")
=> "Delivered-To: unknown@example.comnDate:Wed, 28 May 2014 17:18:19 +0900
(JST)nFrom: xxxxxxx@docomo.ne.jpnTo: unknown@example.comnSubject: test
nMessage-ID: <xxxxx@docomo.ne.jp>nMIME-Version: 1.0nContent-Type: text/plain;
charset="Shift_JIS"nContent-Transfer-Encoding: 8bitnn
x82xA0x82xA2x82xA4x82xA6x82xA8nnx82xB1x82̃x81x81[x83x8Bx82̓e
x83Xx83gx97px82̃x81x81[x83x8Bx82łxB7x81Bnnx8DxA1x8CxE3x82Ƃ
xE0x82xE6x82낵x82xADx82xA8x8A x90x82xB5x8F x82!xB7x81In"
Mail.new(File.read("japanese_shift_jis.eml")).to_s
=> "Date:Wed, 28 May 2014 17:18:19 +0900rnFrom: xxxxxxx@docomo.ne.jprnTo:
unknown@example.comrnMessage-ID: <xxxxx@docomo.ne.jp>rnSubject: testr
nMime-Version: 1.0rnContent-Type: text/plain;rn charset=Shift_JISrnContent-
Transfer-Encoding: base64rnDelivered-To: unknown@example.comrnr
ngqCCooKkgqaCqAoKgrGCzIOBgVuDi4LNg2WDWINnl3CCzIOBgVuDi4LFgreBr
nQgoKjaGM44LGguCC5oLrgrWCrYKoiuiCopBcgrWP44KwgtyCt4FJCg==rn"
16 5 29
• Content-Transfer-Encoding
body Encoding
• Mail
Encoding
• Mail
Encoding
16 5 29
• RFC
•
•
2
•
16 5 29
……
•
content-transfer-encoding → Content-Transfer-Encoding
mail gem
16 5 29
:no_header_formatted
PR
16 5 29
To get mail data
• To get header
mail.to
mail.header[:to]
• To get mail body
mail.body.to_s
16 5 29
To modify header
• mail.to = ‘maki@example.com’
• smtp_envelope_to
mail.smtp_envelope_to = ‘maki@example.org’
16 5 29
To get attachment files
• To get attachment files
mail.attachments
• readme ……
• HTML HTML
16 5 29
nested multipart
header part
Content-Type: multipart/mixed;
boundary="----
=_Part_2192_32400445.1115745999735"
multipart header
multipart header
multipart body
mail.parts << Mail::Part.new do
“This is multipart body”
end
mail.parts << Mail::Part.new do
part do
“This is nested multipart body”
end
end
Content-Type: text/plain;
boundary="--
==_mimepart_57387affe6d00_c2e8082dbf8514b
nested multipart
16 5 29
attachment
Mail::Message
Mail::Part(Mail::Message
16 5 29
• Mail::Part
attachment?
• mail.parts.select(&:attachment?)
•
16 5 29
Mail
• Mail::Parser
• Ragel
DSL
• Ruby
•
16 5 29
16 5 29
Thanks to mail
• mail
•
•
16 5 29

More Related Content

Viewers also liked

Is your ultimate goal college education powerpoint
Is your ultimate goal college education powerpointIs your ultimate goal college education powerpoint
Is your ultimate goal college education powerpointNoralyGuerrero
 
Michael Gilmour: 50% ROI Per Year on Domain Name Parking
Michael Gilmour: 50% ROI Per Year on Domain Name ParkingMichael Gilmour: 50% ROI Per Year on Domain Name Parking
Michael Gilmour: 50% ROI Per Year on Domain Name Parkingdomainsherpa
 
Richard Swerdlow: The Global Internet Real Estate Developer
Richard Swerdlow: The Global Internet Real Estate DeveloperRichard Swerdlow: The Global Internet Real Estate Developer
Richard Swerdlow: The Global Internet Real Estate Developerdomainsherpa
 
Experiències dèxit a la fp angles a la fp
Experiències dèxit a la fp angles a la fpExperiències dèxit a la fp angles a la fp
Experiències dèxit a la fp angles a la fpJose Moratal Miñana
 
Race Horse Steroids
Race Horse SteroidsRace Horse Steroids
Race Horse Steroidsnorrell44294
 
How to integrate technology into your classroom
How to integrate technology into your classroomHow to integrate technology into your classroom
How to integrate technology into your classroomtnjestes
 
True immigration stories
True immigration storiesTrue immigration stories
True immigration storieshill18
 

Viewers also liked (20)

Moral Panics over the Internet
Moral Panics over the InternetMoral Panics over the Internet
Moral Panics over the Internet
 
Next Internet Users: Perspectives on the UK and Poland
Next Internet Users: Perspectives on the UK and PolandNext Internet Users: Perspectives on the UK and Poland
Next Internet Users: Perspectives on the UK and Poland
 
Addiction
AddictionAddiction
Addiction
 
Emocions
EmocionsEmocions
Emocions
 
Is your ultimate goal college education powerpoint
Is your ultimate goal college education powerpointIs your ultimate goal college education powerpoint
Is your ultimate goal college education powerpoint
 
Power&amp;5th windsor-2016
Power&amp;5th windsor-2016Power&amp;5th windsor-2016
Power&amp;5th windsor-2016
 
Michael Gilmour: 50% ROI Per Year on Domain Name Parking
Michael Gilmour: 50% ROI Per Year on Domain Name ParkingMichael Gilmour: 50% ROI Per Year on Domain Name Parking
Michael Gilmour: 50% ROI Per Year on Domain Name Parking
 
Educ651Presentation
Educ651PresentationEduc651Presentation
Educ651Presentation
 
Next generation user for ofcom-2012
Next generation user for ofcom-2012Next generation user for ofcom-2012
Next generation user for ofcom-2012
 
Richard Swerdlow: The Global Internet Real Estate Developer
Richard Swerdlow: The Global Internet Real Estate DeveloperRichard Swerdlow: The Global Internet Real Estate Developer
Richard Swerdlow: The Global Internet Real Estate Developer
 
Irene foodproject
Irene foodprojectIrene foodproject
Irene foodproject
 
Tprc cultures-2016
Tprc cultures-2016Tprc cultures-2016
Tprc cultures-2016
 
Experiències dèxit a la fp angles a la fp
Experiències dèxit a la fp angles a la fpExperiències dèxit a la fp angles a la fp
Experiències dèxit a la fp angles a la fp
 
Race Horse Steroids
Race Horse SteroidsRace Horse Steroids
Race Horse Steroids
 
Must Know Web 2.0
Must Know Web 2.0Must Know Web 2.0
Must Know Web 2.0
 
How to integrate technology into your classroom
How to integrate technology into your classroomHow to integrate technology into your classroom
How to integrate technology into your classroom
 
インターンの心得
インターンの心得インターンの心得
インターンの心得
 
Bondelandet
BondelandetBondelandet
Bondelandet
 
True immigration stories
True immigration storiesTrue immigration stories
True immigration stories
 
Why Journalism Needs the Fifth Estate
Why Journalism Needs the Fifth EstateWhy Journalism Needs the Fifth Estate
Why Journalism Needs the Fifth Estate
 

More from Maki Toshio

Rails 6.1 → 7.0アップデート記録
Rails 6.1 → 7.0アップデート記録Rails 6.1 → 7.0アップデート記録
Rails 6.1 → 7.0アップデート記録Maki Toshio
 
自社サービスのAPIをOAuth2対応にして公開した
自社サービスのAPIをOAuth2対応にして公開した自社サービスのAPIをOAuth2対応にして公開した
自社サービスのAPIをOAuth2対応にして公開したMaki Toshio
 
Searched gems which supports only ruby 2.6
Searched gems which supports only ruby 2.6Searched gems which supports only ruby 2.6
Searched gems which supports only ruby 2.6Maki Toshio
 
ActiveRecordで複雑なクエリを書くのは間違っているのか
ActiveRecordで複雑なクエリを書くのは間違っているのかActiveRecordで複雑なクエリを書くのは間違っているのか
ActiveRecordで複雑なクエリを書くのは間違っているのかMaki Toshio
 
やさしいGemパッチの作り方
やさしいGemパッチの作り方やさしいGemパッチの作り方
やさしいGemパッチの作り方Maki Toshio
 
ファイルシステムのスナップショット機能でバックアップを取得する
ファイルシステムのスナップショット機能でバックアップを取得するファイルシステムのスナップショット機能でバックアップを取得する
ファイルシステムのスナップショット機能でバックアップを取得するMaki Toshio
 
Cloud Foundry Day in Tokyo Lightning Talk - Cloud Foundry over the Proxy
Cloud Foundry Day in Tokyo Lightning Talk - Cloud Foundry over the ProxyCloud Foundry Day in Tokyo Lightning Talk - Cloud Foundry over the Proxy
Cloud Foundry Day in Tokyo Lightning Talk - Cloud Foundry over the ProxyMaki Toshio
 
明日から使える(?)Rubyトリビア
明日から使える(?)Rubyトリビア明日から使える(?)Rubyトリビア
明日から使える(?)RubyトリビアMaki Toshio
 
Rubyで簡単にremote access apiを実行する
Rubyで簡単にremote access apiを実行するRubyで簡単にremote access apiを実行する
Rubyで簡単にremote access apiを実行するMaki Toshio
 
レガシーコード改善ガイド
レガシーコード改善ガイドレガシーコード改善ガイド
レガシーコード改善ガイドMaki Toshio
 
Ruby on rails on hudsonの活用事例
Ruby on rails on hudsonの活用事例Ruby on rails on hudsonの活用事例
Ruby on rails on hudsonの活用事例Maki Toshio
 

More from Maki Toshio (11)

Rails 6.1 → 7.0アップデート記録
Rails 6.1 → 7.0アップデート記録Rails 6.1 → 7.0アップデート記録
Rails 6.1 → 7.0アップデート記録
 
自社サービスのAPIをOAuth2対応にして公開した
自社サービスのAPIをOAuth2対応にして公開した自社サービスのAPIをOAuth2対応にして公開した
自社サービスのAPIをOAuth2対応にして公開した
 
Searched gems which supports only ruby 2.6
Searched gems which supports only ruby 2.6Searched gems which supports only ruby 2.6
Searched gems which supports only ruby 2.6
 
ActiveRecordで複雑なクエリを書くのは間違っているのか
ActiveRecordで複雑なクエリを書くのは間違っているのかActiveRecordで複雑なクエリを書くのは間違っているのか
ActiveRecordで複雑なクエリを書くのは間違っているのか
 
やさしいGemパッチの作り方
やさしいGemパッチの作り方やさしいGemパッチの作り方
やさしいGemパッチの作り方
 
ファイルシステムのスナップショット機能でバックアップを取得する
ファイルシステムのスナップショット機能でバックアップを取得するファイルシステムのスナップショット機能でバックアップを取得する
ファイルシステムのスナップショット機能でバックアップを取得する
 
Cloud Foundry Day in Tokyo Lightning Talk - Cloud Foundry over the Proxy
Cloud Foundry Day in Tokyo Lightning Talk - Cloud Foundry over the ProxyCloud Foundry Day in Tokyo Lightning Talk - Cloud Foundry over the Proxy
Cloud Foundry Day in Tokyo Lightning Talk - Cloud Foundry over the Proxy
 
明日から使える(?)Rubyトリビア
明日から使える(?)Rubyトリビア明日から使える(?)Rubyトリビア
明日から使える(?)Rubyトリビア
 
Rubyで簡単にremote access apiを実行する
Rubyで簡単にremote access apiを実行するRubyで簡単にremote access apiを実行する
Rubyで簡単にremote access apiを実行する
 
レガシーコード改善ガイド
レガシーコード改善ガイドレガシーコード改善ガイド
レガシーコード改善ガイド
 
Ruby on rails on hudsonの活用事例
Ruby on rails on hudsonの活用事例Ruby on rails on hudsonの活用事例
Ruby on rails on hudsonの活用事例
 

Recently uploaded

Vishratwadi & Ghorpadi Bridge Tender documents
Vishratwadi & Ghorpadi Bridge Tender documentsVishratwadi & Ghorpadi Bridge Tender documents
Vishratwadi & Ghorpadi Bridge Tender documentsSachinPawar510423
 
Instrumentation, measurement and control of bio process parameters ( Temperat...
Instrumentation, measurement and control of bio process parameters ( Temperat...Instrumentation, measurement and control of bio process parameters ( Temperat...
Instrumentation, measurement and control of bio process parameters ( Temperat...121011101441
 
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort serviceGurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort servicejennyeacort
 
Risk Assessment For Installation of Drainage Pipes.pdf
Risk Assessment For Installation of Drainage Pipes.pdfRisk Assessment For Installation of Drainage Pipes.pdf
Risk Assessment For Installation of Drainage Pipes.pdfROCENODodongVILLACER
 
computer application and construction management
computer application and construction managementcomputer application and construction management
computer application and construction managementMariconPadriquez1
 
welding defects observed during the welding
welding defects observed during the weldingwelding defects observed during the welding
welding defects observed during the weldingMuhammadUzairLiaqat
 
IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024Mark Billinghurst
 
US Department of Education FAFSA Week of Action
US Department of Education FAFSA Week of ActionUS Department of Education FAFSA Week of Action
US Department of Education FAFSA Week of ActionMebane Rash
 
Call Us ≽ 8377877756 ≼ Call Girls In Shastri Nagar (Delhi)
Call Us ≽ 8377877756 ≼ Call Girls In Shastri Nagar (Delhi)Call Us ≽ 8377877756 ≼ Call Girls In Shastri Nagar (Delhi)
Call Us ≽ 8377877756 ≼ Call Girls In Shastri Nagar (Delhi)dollysharma2066
 
Introduction-To-Agricultural-Surveillance-Rover.pptx
Introduction-To-Agricultural-Surveillance-Rover.pptxIntroduction-To-Agricultural-Surveillance-Rover.pptx
Introduction-To-Agricultural-Surveillance-Rover.pptxk795866
 
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdfCCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdfAsst.prof M.Gokilavani
 
Software and Systems Engineering Standards: Verification and Validation of Sy...
Software and Systems Engineering Standards: Verification and Validation of Sy...Software and Systems Engineering Standards: Verification and Validation of Sy...
Software and Systems Engineering Standards: Verification and Validation of Sy...VICTOR MAESTRE RAMIREZ
 
Work Experience-Dalton Park.pptxfvvvvvvv
Work Experience-Dalton Park.pptxfvvvvvvvWork Experience-Dalton Park.pptxfvvvvvvv
Work Experience-Dalton Park.pptxfvvvvvvvLewisJB
 
Oxy acetylene welding presentation note.
Oxy acetylene welding presentation note.Oxy acetylene welding presentation note.
Oxy acetylene welding presentation note.eptoze12
 
Piping Basic stress analysis by engineering
Piping Basic stress analysis by engineeringPiping Basic stress analysis by engineering
Piping Basic stress analysis by engineeringJuanCarlosMorales19600
 
Sachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
Sachpazis Costas: Geotechnical Engineering: A student's Perspective IntroductionSachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
Sachpazis Costas: Geotechnical Engineering: A student's Perspective IntroductionDr.Costas Sachpazis
 
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube ExchangerStudy on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube ExchangerAnamika Sarkar
 

Recently uploaded (20)

Vishratwadi & Ghorpadi Bridge Tender documents
Vishratwadi & Ghorpadi Bridge Tender documentsVishratwadi & Ghorpadi Bridge Tender documents
Vishratwadi & Ghorpadi Bridge Tender documents
 
Instrumentation, measurement and control of bio process parameters ( Temperat...
Instrumentation, measurement and control of bio process parameters ( Temperat...Instrumentation, measurement and control of bio process parameters ( Temperat...
Instrumentation, measurement and control of bio process parameters ( Temperat...
 
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort serviceGurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
 
Risk Assessment For Installation of Drainage Pipes.pdf
Risk Assessment For Installation of Drainage Pipes.pdfRisk Assessment For Installation of Drainage Pipes.pdf
Risk Assessment For Installation of Drainage Pipes.pdf
 
computer application and construction management
computer application and construction managementcomputer application and construction management
computer application and construction management
 
welding defects observed during the welding
welding defects observed during the weldingwelding defects observed during the welding
welding defects observed during the welding
 
IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024
 
US Department of Education FAFSA Week of Action
US Department of Education FAFSA Week of ActionUS Department of Education FAFSA Week of Action
US Department of Education FAFSA Week of Action
 
Call Us ≽ 8377877756 ≼ Call Girls In Shastri Nagar (Delhi)
Call Us ≽ 8377877756 ≼ Call Girls In Shastri Nagar (Delhi)Call Us ≽ 8377877756 ≼ Call Girls In Shastri Nagar (Delhi)
Call Us ≽ 8377877756 ≼ Call Girls In Shastri Nagar (Delhi)
 
Introduction-To-Agricultural-Surveillance-Rover.pptx
Introduction-To-Agricultural-Surveillance-Rover.pptxIntroduction-To-Agricultural-Surveillance-Rover.pptx
Introduction-To-Agricultural-Surveillance-Rover.pptx
 
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdfCCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
 
POWER SYSTEMS-1 Complete notes examples
POWER SYSTEMS-1 Complete notes  examplesPOWER SYSTEMS-1 Complete notes  examples
POWER SYSTEMS-1 Complete notes examples
 
Software and Systems Engineering Standards: Verification and Validation of Sy...
Software and Systems Engineering Standards: Verification and Validation of Sy...Software and Systems Engineering Standards: Verification and Validation of Sy...
Software and Systems Engineering Standards: Verification and Validation of Sy...
 
Work Experience-Dalton Park.pptxfvvvvvvv
Work Experience-Dalton Park.pptxfvvvvvvvWork Experience-Dalton Park.pptxfvvvvvvv
Work Experience-Dalton Park.pptxfvvvvvvv
 
young call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Service
young call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Serviceyoung call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Service
young call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Service
 
Oxy acetylene welding presentation note.
Oxy acetylene welding presentation note.Oxy acetylene welding presentation note.
Oxy acetylene welding presentation note.
 
Piping Basic stress analysis by engineering
Piping Basic stress analysis by engineeringPiping Basic stress analysis by engineering
Piping Basic stress analysis by engineering
 
🔝9953056974🔝!!-YOUNG call girls in Rajendra Nagar Escort rvice Shot 2000 nigh...
🔝9953056974🔝!!-YOUNG call girls in Rajendra Nagar Escort rvice Shot 2000 nigh...🔝9953056974🔝!!-YOUNG call girls in Rajendra Nagar Escort rvice Shot 2000 nigh...
🔝9953056974🔝!!-YOUNG call girls in Rajendra Nagar Escort rvice Shot 2000 nigh...
 
Sachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
Sachpazis Costas: Geotechnical Engineering: A student's Perspective IntroductionSachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
Sachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
 
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube ExchangerStudy on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
 

メール製品を作って気づいたmailライブラリの光と闇について語る