SlideShare a Scribd company logo
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

Moral Panics over the Internet
Moral Panics over the InternetMoral 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
Oxford Martin Centre, OII, and Computer Science at the University of Oxford
 
Addiction
AddictionAddiction
Addiction
Robert Jensen
 
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
NoralyGuerrero
 
Power&amp;5th windsor-2016
Power&amp;5th windsor-2016Power&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
domainsherpa
 
Next generation user for ofcom-2012
Next generation user for ofcom-2012Next 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
domainsherpa
 
Tprc cultures-2016
Tprc cultures-2016Tprc 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 fpJose Moratal Miñana
 
Race Horse Steroids
Race Horse SteroidsRace Horse Steroids
Race Horse Steroidsnorrell44294
 
Must Know Web 2.0
Must Know Web 2.0Must Know Web 2.0
Must Know Web 2.0
cynthiafarrell
 
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
 
Why Journalism Needs the Fifth Estate
Why Journalism Needs the Fifth EstateWhy Journalism Needs the Fifth Estate

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.6
Maki 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 Proxy
Maki 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

Student information management system project report ii.pdf
Student information management system project report ii.pdfStudent information management system project report ii.pdf
Student information management system project report ii.pdf
Kamal Acharya
 
ethical hacking in wireless-hacking1.ppt
ethical hacking in wireless-hacking1.pptethical hacking in wireless-hacking1.ppt
ethical hacking in wireless-hacking1.ppt
Jayaprasanna4
 
The role of big data in decision making.
The role of big data in decision making.The role of big data in decision making.
The role of big data in decision making.
ankuprajapati0525
 
CFD Simulation of By-pass Flow in a HRSG module by R&R Consult.pptx
CFD Simulation of By-pass Flow in a HRSG module by R&R Consult.pptxCFD Simulation of By-pass Flow in a HRSG module by R&R Consult.pptx
CFD Simulation of By-pass Flow in a HRSG module by R&R Consult.pptx
R&R Consult
 
Planning Of Procurement o different goods and services
Planning Of Procurement o different goods and servicesPlanning Of Procurement o different goods and services
Planning Of Procurement o different goods and services
JoytuBarua2
 
space technology lecture notes on satellite
space technology lecture notes on satellitespace technology lecture notes on satellite
space technology lecture notes on satellite
ongomchris
 
Top 10 Oil and Gas Projects in Saudi Arabia 2024.pdf
Top 10 Oil and Gas Projects in Saudi Arabia 2024.pdfTop 10 Oil and Gas Projects in Saudi Arabia 2024.pdf
Top 10 Oil and Gas Projects in Saudi Arabia 2024.pdf
Teleport Manpower Consultant
 
Water Industry Process Automation and Control Monthly - May 2024.pdf
Water Industry Process Automation and Control Monthly - May 2024.pdfWater Industry Process Automation and Control Monthly - May 2024.pdf
Water Industry Process Automation and Control Monthly - May 2024.pdf
Water Industry Process Automation & Control
 
Hybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdf
Hybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdfHybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdf
Hybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdf
fxintegritypublishin
 
一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单专业办理
一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单专业办理一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单专业办理
一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单专业办理
zwunae
 
power quality voltage fluctuation UNIT - I.pptx
power quality voltage fluctuation UNIT - I.pptxpower quality voltage fluctuation UNIT - I.pptx
power quality voltage fluctuation UNIT - I.pptx
ViniHema
 
The Benefits and Techniques of Trenchless Pipe Repair.pdf
The Benefits and Techniques of Trenchless Pipe Repair.pdfThe Benefits and Techniques of Trenchless Pipe Repair.pdf
The Benefits and Techniques of Trenchless Pipe Repair.pdf
Pipe Restoration Solutions
 
road safety engineering r s e unit 3.pdf
road safety engineering  r s e unit 3.pdfroad safety engineering  r s e unit 3.pdf
road safety engineering r s e unit 3.pdf
VENKATESHvenky89705
 
DESIGN A COTTON SEED SEPARATION MACHINE.docx
DESIGN A COTTON SEED SEPARATION MACHINE.docxDESIGN A COTTON SEED SEPARATION MACHINE.docx
DESIGN A COTTON SEED SEPARATION MACHINE.docx
FluxPrime1
 
HYDROPOWER - Hydroelectric power generation
HYDROPOWER - Hydroelectric power generationHYDROPOWER - Hydroelectric power generation
HYDROPOWER - Hydroelectric power generation
Robbie Edward Sayers
 
H.Seo, ICLR 2024, MLILAB, KAIST AI.pdf
H.Seo,  ICLR 2024, MLILAB,  KAIST AI.pdfH.Seo,  ICLR 2024, MLILAB,  KAIST AI.pdf
H.Seo, ICLR 2024, MLILAB, KAIST AI.pdf
MLILAB
 
Railway Signalling Principles Edition 3.pdf
Railway Signalling Principles Edition 3.pdfRailway Signalling Principles Edition 3.pdf
Railway Signalling Principles Edition 3.pdf
TeeVichai
 
Hierarchical Digital Twin of a Naval Power System
Hierarchical Digital Twin of a Naval Power SystemHierarchical Digital Twin of a Naval Power System
Hierarchical Digital Twin of a Naval Power System
Kerry Sado
 
block diagram and signal flow graph representation
block diagram and signal flow graph representationblock diagram and signal flow graph representation
block diagram and signal flow graph representation
Divya Somashekar
 
Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...
Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...
Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...
AJAYKUMARPUND1
 

Recently uploaded (20)

Student information management system project report ii.pdf
Student information management system project report ii.pdfStudent information management system project report ii.pdf
Student information management system project report ii.pdf
 
ethical hacking in wireless-hacking1.ppt
ethical hacking in wireless-hacking1.pptethical hacking in wireless-hacking1.ppt
ethical hacking in wireless-hacking1.ppt
 
The role of big data in decision making.
The role of big data in decision making.The role of big data in decision making.
The role of big data in decision making.
 
CFD Simulation of By-pass Flow in a HRSG module by R&R Consult.pptx
CFD Simulation of By-pass Flow in a HRSG module by R&R Consult.pptxCFD Simulation of By-pass Flow in a HRSG module by R&R Consult.pptx
CFD Simulation of By-pass Flow in a HRSG module by R&R Consult.pptx
 
Planning Of Procurement o different goods and services
Planning Of Procurement o different goods and servicesPlanning Of Procurement o different goods and services
Planning Of Procurement o different goods and services
 
space technology lecture notes on satellite
space technology lecture notes on satellitespace technology lecture notes on satellite
space technology lecture notes on satellite
 
Top 10 Oil and Gas Projects in Saudi Arabia 2024.pdf
Top 10 Oil and Gas Projects in Saudi Arabia 2024.pdfTop 10 Oil and Gas Projects in Saudi Arabia 2024.pdf
Top 10 Oil and Gas Projects in Saudi Arabia 2024.pdf
 
Water Industry Process Automation and Control Monthly - May 2024.pdf
Water Industry Process Automation and Control Monthly - May 2024.pdfWater Industry Process Automation and Control Monthly - May 2024.pdf
Water Industry Process Automation and Control Monthly - May 2024.pdf
 
Hybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdf
Hybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdfHybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdf
Hybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdf
 
一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单专业办理
一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单专业办理一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单专业办理
一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单专业办理
 
power quality voltage fluctuation UNIT - I.pptx
power quality voltage fluctuation UNIT - I.pptxpower quality voltage fluctuation UNIT - I.pptx
power quality voltage fluctuation UNIT - I.pptx
 
The Benefits and Techniques of Trenchless Pipe Repair.pdf
The Benefits and Techniques of Trenchless Pipe Repair.pdfThe Benefits and Techniques of Trenchless Pipe Repair.pdf
The Benefits and Techniques of Trenchless Pipe Repair.pdf
 
road safety engineering r s e unit 3.pdf
road safety engineering  r s e unit 3.pdfroad safety engineering  r s e unit 3.pdf
road safety engineering r s e unit 3.pdf
 
DESIGN A COTTON SEED SEPARATION MACHINE.docx
DESIGN A COTTON SEED SEPARATION MACHINE.docxDESIGN A COTTON SEED SEPARATION MACHINE.docx
DESIGN A COTTON SEED SEPARATION MACHINE.docx
 
HYDROPOWER - Hydroelectric power generation
HYDROPOWER - Hydroelectric power generationHYDROPOWER - Hydroelectric power generation
HYDROPOWER - Hydroelectric power generation
 
H.Seo, ICLR 2024, MLILAB, KAIST AI.pdf
H.Seo,  ICLR 2024, MLILAB,  KAIST AI.pdfH.Seo,  ICLR 2024, MLILAB,  KAIST AI.pdf
H.Seo, ICLR 2024, MLILAB, KAIST AI.pdf
 
Railway Signalling Principles Edition 3.pdf
Railway Signalling Principles Edition 3.pdfRailway Signalling Principles Edition 3.pdf
Railway Signalling Principles Edition 3.pdf
 
Hierarchical Digital Twin of a Naval Power System
Hierarchical Digital Twin of a Naval Power SystemHierarchical Digital Twin of a Naval Power System
Hierarchical Digital Twin of a Naval Power System
 
block diagram and signal flow graph representation
block diagram and signal flow graph representationblock diagram and signal flow graph representation
block diagram and signal flow graph representation
 
Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...
Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...
Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...
 

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