Slide 1

Slide 1 text

1 GoݴޠͰߦ͏ϝʔϧղੳ OPTiM × every Golang Developer Night 2024/07/02 גࣜձࣾΤϒϦʔ ͖ΐʔɻ

Slide 2

Slide 2 text

Copyright © 2015 every, Inc. All rights reserved. 2 ࣗݾ঺հ - ໊લ - ͖ΐʔɻ - ෦ॺ - ։ൃຊ෦ɺDELISH KITCHEN։ൃ෦ - ࠷ۙ஥ྑ͘ͳͬͨGoͷύοέʔδ - math/rand - Ωʔϫʔυ - ٶ৓ग़਎ - 3౓ͷ൧ͱ೔ຊञ - όΠΫ - Ϥʔϩούཱྀߦ - ίʔώʔ - Vtuber - ήʔϜ - Ξχϝ

Slide 3

Slide 3 text

Copyright © 2015 every, Inc. All rights reserved. 3 ຊ೔ͷ͓඼ॻ͖ - GoݴޠͰߦ͏ϝʔϧղੳ - ಋೖ - ϝʔϧϔομʔʹ͍ͭͯ - ࣮ࡍʹղੳͯ͠ΈΑ͏ - ͲͷΑ͏ͳ৔໘Ͱϝʔϧղੳ͍͔ͨ͠ - ·ͱΊ

Slide 4

Slide 4 text

Copyright © 2015 every, Inc. All rights reserved. 4 Έͳ͞ΜϝʔϧΛૹͬͨ͜ͱ͸͋Γ·͔͢ʁ

Slide 5

Slide 5 text

Copyright © 2015 every, Inc. All rights reserved. 5 Έͳ͞ΜϝʔϧΛૹͬͨ͜ͱ͸͋Γ·͔͢ʁ

Slide 6

Slide 6 text

Copyright © 2015 every, Inc. All rights reserved. 6

Slide 7

Slide 7 text

Copyright © 2015 every, Inc. All rights reserved. 7 Έͳ͞ΜϝʔϧΛૹͬͨ͜ͱ͸͋Γ·͔͢ʁ Telnet

Slide 8

Slide 8 text

Copyright © 2015 every, Inc. All rights reserved. 8 Έͳ͞ΜϝʔϧΛૹͬͨ͜ͱ͸͋Γ·͔͢ʁ Telnet - ϦϞʔτίϯϐϡʔλͱର࿩͢ΔͨΊʹߏங͞ΕͨίϯϐϡʔλϓϩτίϧͷҰͭ - ଞͷϓϩτίϧͷྫ - SSH - SFTP - VNC

Slide 9

Slide 9 text

Copyright © 2015 every, Inc. All rights reserved. 9 $ docker run -d -p 8025:8025 -p 1025:1025 --name test_mailhog mailhog/mailhog Header - MAIL FROM: - RCPT TO: - SUBJECT: - FROM: - TO: Body - Hello, World! . ੺Ͱғ͍ͬͯΔ෦෼ɿࣗ෼͕ೖྗͨ͠Օॴ

Slide 10

Slide 10 text

Copyright © 2015 every, Inc. All rights reserved. 10 $ docker run -d -p 8025:8025 -p 1025:1025 --name test_mailhog mailhog/mailhog [email protected] [email protected]

Slide 11

Slide 11 text

Copyright © 2015 every, Inc. All rights reserved. 11 $ docker run -d -p 8025:8025 -p 1025:1025 --name test_mailhog mailhog/mailhog Q. - ͳΓ͢·͠ରࡦ͸Ͳ͏΍ͬͯΔͷʁ - ͲΜͳϝʔϧϔομʔ͕͋ͬͯɺͳΜͷͨΊʹ࢖ΘΕ͍ͯΔͷʁ - GoͰϝʔϧΛղੳ͢Δʹ͸Ͳ͏͢Ε͹ྑ͍ʁ

Slide 12

Slide 12 text

12 ϝʔϧϔομʔʹ͍ͭͯ

Slide 13

Slide 13 text

Copyright © 2015 every, Inc. All rights reserved. 13 ͦ΋ͦ΋ϝʔϧϔομʔͱ͸ʁ - ϝʔϧϔομͱ͸ɺϝʔϧͷৄࡉ৘ใ͕ॻ͔Ε͍ͯΔ෦෼ͷ͜ͱ - ϝʔϧ͕഑ૹ͞Εͨܦ࿏΍࣌ؒɺܦ༝ͨ͠αʔόʔͳͲ͕ه࿥͞Ε͍ͯΔ - From: - ૹ৴ऀͷϝʔϧΞυϨε - To: - ड৴ऀͷϝʔϧΞυϨε - Subject: - ϝʔϧͷ໊݅ - Received: - ϝʔϧ͕ܦ༝ͨ͠αʔόʔͱͦͷ೔࣌ - Content-Type: - ϝʔϧͷຊจͷܗࣜʢྫɿtext/plain, text/htmlʣ - MIME-Version: - ϝʔϧ͕ MIMEن֨Λ࢖༻͍ͯ͠Δ৔߹ͷόʔδϣϯ ϝʔϧϔομʔ͸ɺϝʔϧͷτϥϒϧγϡʔςΟϯάɺεύϜͷݕग़ɺηΩϡϦςΟ෼ੳͳͲʹ࢖༻͞ΕΔ

Slide 14

Slide 14 text

Copyright © 2015 every, Inc. All rights reserved. 14

Slide 15

Slide 15 text

Copyright © 2015 every, Inc. All rights reserved. 15 - RFC2822 Ͱنఆ͞Εͨϝʔϧϓϩ τίϧͰߏ੒͞Ε͍ͯΔ - ASCII ίʔυͰߏ੒͞ΕΔ͜ͱ - Ұߦ͸ 78 จࣈҎԼ͕ਪ঑ - Header ϑΟʔϧυ͸ɺϑΟʔϧυ ໊ͷޙʹίϩϯ(":")ɺϑΟʔϧυ ຊମ͕ଓ͖ɺCRLF Ͱऴྃ - Body ͕࢝·Δલ͸ۭߦʹ͢Δ

Slide 16

Slide 16 text

16 ࣮ࡍʹղੳͯ͠ΈΑ͏

Slide 17

Slide 17 text

Copyright © 2015 every, Inc. All rights reserved. 17 ࣮ࡍʹղੳͯ͠Έͨ - net/mail - Go Packages - Goͷඪ४ύοέʔδͷҰͭ - ϝʔϧϝοηʔδͷղੳΛఏڙ͍ͯ͠Δ - جຊతͳ࢖͍ํ

Slide 18

Slide 18 text

Copyright © 2015 every, Inc. All rights reserved. 18 ⚠ ݸਓ৘ใؚ͕·Ε͍ͯΔ෦෼͸ ɹফͯ͋͠Γ·͢

Slide 19

Slide 19 text

Copyright © 2015 every, Inc. All rights reserved. 19 Message.Header Delivered-To: ϝʔϧ͕࠷ऴతʹ഑৴͞Εͨड৴ऀͷϝʔϧΞυϨε Received: ϝʔϧ͕ܦ༝֤ͨ͠αʔόʔʹΑͬͯ௥Ճ͞Εɺϝʔϧͷసૹܦ࿏ʢෳ਺ͷReceivedϔομʔ͕ଘࡏ͢Δ͜ͱ͕͋Δʣ ARC-Seal, ARC-Message-Signature, ARC-Authentication-Results: Authenticated Received Chain (ARC)ʹؔ࿈͢Δϔομʔʢϝʔϧ͕సૹ͞ΕΔաఔͰͷೝূ݁ՌΛอ࣋ʣ Return-Path: ό΢ϯεϝοηʔδʢ഑৴ෆೳ௨஌ʣ͕ૹΒΕΔࡍͷฦ৴ઌΞυϨε Received-SPF: Sender Policy Framework (SPF)ͷݕূ݁Ռʢϝʔϧ͕ਖ਼౰ͳૹ৴ݩ͔ΒૹΒΕ͔ͨͲ͏͔Λ֬ೝ͢Δʣ Authentication-Results: ϝʔϧ͕ೝূϓϩηεʢDKIMɺSPFɺDMARCͳͲʣΛ௨ա͔ͨ͠Ͳ͏͔ͷ݁Ռ DKIM-Signature: DomainKeys Identified Mail (DKIM)ͷॺ໊ʢϝʔϧͷ಺༰͕ૹ৴ऀʹΑͬͯॺ໊͞Εɺ్தͰվ͟Μ͞Ε͍ͯͳ͍͜ͱΛอূʣ X-Google-DKIM-Signature: Google͕௥Ճͨ͠DKIMॺ໊ʢGmail͕ϝʔϧΛॲཧͨ͜͠ͱΛࣔ͢ʣ X-Gm-Message-State: GmailʹΑͬͯ௥Ճ͞Εͨϔομʔʢϝʔϧͷঢ়ଶʹؔ͢Δ৘ใΛؚΉʣ X-Google-Smtp-Source: GmailʹΑͬͯ௥Ճ͞Εͨϔομʔʢϝʔϧͷૹ৴ʹؔ͢Δ௥Ճ৘ใΛؚΉʣ MIME-Version: MIME (Multipurpose Internet Mail Extensions)ͷόʔδϣϯʢϝʔϧ͕ςΩετҎ֎ͷίϯςϯπΛؚΉ͜ͱΛࣔ͢ʣ From: ϝʔϧͷૹ৴ऀͷ໊લͱϝʔϧΞυϨε Date: ϝʔϧ͕ૹ৴͞Εͨ೔࣌ Message-ID: ϝʔϧʹҰҙʹׂΓ౰ͯΒΕͨIDʢϝʔϧͷ௥੻ʹ࢖༻͞ΕΔʣ Subject: ϝʔϧͷ໊݅ To: ϝʔϧͷѼઌΞυϨε Content-Type: ϝʔϧͷຊจ΍ఴ෇ϑΝΠϧͷܗࣜʢMIMEλΠϓʣ Content-Disposition: ఴ෇ϑΝΠϧͷදࣔํ๏΍ϑΝΠϧ໊ Content-Transfer-Encoding: ϝʔϧͷຊจ΍ఴ෇ϑΝΠϧ͕ͲͷΑ͏ʹΤϯίʔυ͞Ε͍ͯΔ͔ Content-ID: ఴ෇ϑΝΠϧʹؔ࿈෇͚ΒΕͨҰҙͷIDʢϝʔϧ಺Ͱࢀর͢Δࡍʹ࢖༻͞ΕΔʣ X-Attachment-Id: Gmail͕ఴ෇ϑΝΠϧʹׂΓ౰ͯͨIDʢϝʔϧ಺Ͱͷఴ෇ϑΝΠϧͷࢀরʹ࢖༻͞ΕΔʣ

Slide 20

Slide 20 text

Copyright © 2015 every, Inc. All rights reserved. 20 Message.Header Delivered-To: ϝʔϧ͕࠷ऴతʹ഑৴͞Εͨड৴ऀͷϝʔϧΞυϨε Received: ϝʔϧ͕ܦ༝֤ͨ͠αʔόʔʹΑͬͯ௥Ճ͞Εɺϝʔϧͷసૹܦ࿏ʢෳ਺ͷReceivedϔομʔ͕ଘࡏ͢Δ͜ͱ͕͋Δʣ ARC-Seal, ARC-Message-Signature, ARC-Authentication-Results: Authenticated Received Chain (ARC)ʹؔ࿈͢Δϔομʔʢϝʔϧ͕సૹ͞ΕΔաఔͰͷೝূ݁ՌΛอ࣋ʣ Return-Path: ό΢ϯεϝοηʔδʢ഑৴ෆೳ௨஌ʣ͕ૹΒΕΔࡍͷฦ৴ઌΞυϨε Received-SPF: Sender Policy Framework (SPF)ͷݕূ݁Ռʢϝʔϧ͕ਖ਼౰ͳૹ৴ݩ͔ΒૹΒΕ͔ͨͲ͏͔Λ֬ೝ͢Δʣ Authentication-Results: ϝʔϧ͕ೝূϓϩηεʢDKIMɺSPFɺDMARCͳͲʣΛ௨ա͔ͨ͠Ͳ͏͔ͷ݁Ռ DKIM-Signature: DomainKeys Identified Mail (DKIM)ͷॺ໊ʢϝʔϧͷ಺༰͕ૹ৴ऀʹΑͬͯॺ໊͞Εɺ్தͰվ͟Μ͞Ε͍ͯͳ͍͜ͱΛอূʣ X-Google-DKIM-Signature: Google͕௥Ճͨ͠DKIMॺ໊ʢGmail͕ϝʔϧΛॲཧͨ͜͠ͱΛࣔ͢ʣ X-Gm-Message-State: GmailʹΑͬͯ௥Ճ͞Εͨϔομʔʢϝʔϧͷঢ়ଶʹؔ͢Δ৘ใΛؚΉʣ X-Google-Smtp-Source: GmailʹΑͬͯ௥Ճ͞Εͨϔομʔʢϝʔϧͷૹ৴ʹؔ͢Δ௥Ճ৘ใΛؚΉʣ MIME-Version: MIME (Multipurpose Internet Mail Extensions)ͷόʔδϣϯʢϝʔϧ͕ςΩετҎ֎ͷίϯςϯπΛؚΉ͜ͱΛࣔ͢ʣ From: ϝʔϧͷૹ৴ऀͷ໊લͱϝʔϧΞυϨε Date: ϝʔϧ͕ૹ৴͞Εͨ೔࣌ Message-ID: ϝʔϧʹҰҙʹׂΓ౰ͯΒΕͨIDʢϝʔϧͷ௥੻ʹ࢖༻͞ΕΔʣ Subject: ϝʔϧͷ໊݅ To: ϝʔϧͷѼઌΞυϨε Content-Type: ϝʔϧͷຊจ΍ఴ෇ϑΝΠϧͷܗࣜʢMIMEλΠϓʣ Content-Disposition: ఴ෇ϑΝΠϧͷදࣔํ๏΍ϑΝΠϧ໊ Content-Transfer-Encoding: ϝʔϧͷຊจ΍ఴ෇ϑΝΠϧ͕ͲͷΑ͏ʹΤϯίʔυ͞Ε͍ͯΔ͔ Content-ID: ఴ෇ϑΝΠϧʹؔ࿈෇͚ΒΕͨҰҙͷIDʢϝʔϧ಺Ͱࢀর͢Δࡍʹ࢖༻͞ΕΔʣ X-Attachment-Id: Gmail͕ఴ෇ϑΝΠϧʹׂΓ౰ͯͨIDʢϝʔϧ಺Ͱͷఴ෇ϑΝΠϧͷࢀরʹ࢖༻͞ΕΔʣ ܦ༝ͨ͠αʔόʔɺIPΞυϨεͳͲ͔Β ෆ৹ͳαʔόʔ͔ΒૹΒΕ͍ͯͳ͍͔֬ೝͰ͖Δ ͳΓ͢·͠ରࡦ ͲͷΑ͏ͳίϯςϯπɺܗࣜͳͷ͔Θ͔Δ

Slide 21

Slide 21 text

Copyright © 2015 every, Inc. All rights reserved. 21

Slide 22

Slide 22 text

Copyright © 2015 every, Inc. All rights reserved. 22 Message.Body Content-Type: multipart/mixed; boundary="000000000000367976061c1205d3" MIME Ϛϧνύʔτϝοηʔδ - ςΩετ΍ htmlɺը૾ͳͲͦΕ ͧΕҟͳΔύʔτʹ෼͚ɺͦΕ ΒΛ૊Έ߹Θͤߏ੒͞Εͨ΋ͷ - ෳ਺ͷϑΝΠϧΛిࢠϝʔϧʹ ఴ෇͢Δͱ͖ͳͲʹ࢖༻͞ΕΔ

Slide 23

Slide 23 text

Copyright © 2015 every, Inc. All rights reserved. 23 Message.Body Content-Type: multipart/mixed; boundary="000000000000367976061c1205d3" MIME Ϛϧνύʔτϝοηʔδ - ςΩετ΍ htmlɺը૾ͳͲͦΕ ͧΕҟͳΔύʔτʹ෼͚ɺͦΕ ΒΛ૊Έ߹Θͤߏ੒͞Εͨ΋ͷ - ෳ਺ͷϑΝΠϧΛిࢠϝʔϧʹ ఴ෇͢Δͱ͖ͳͲʹ࢖༻͞ΕΔ

Slide 24

Slide 24 text

24 ͲͷΑ͏ͳ৔໘Ͱϝʔϧղੳ͍͔ͨ͠

Slide 25

Slide 25 text

Copyright © 2015 every, Inc. All rights reserved. 25 ྫ͑͹ - ސ٬αϙʔτͷࣗಈԽ - αϙʔτʹૹΒΕͯ͘ΔϝʔϧΛղੳɺ಺༰ʹج͍ͮͯαϙʔτνʔϜ΁సૹ - https://tech.every.tv/entry/2024/06/06/192547 - Α͋͘Δ࣭໰ʹରͯࣗ͠ಈԠ౴ AWSͰड͚औͬͨϝʔϧΛసૹ͢Δྫ→ - ϝʔϧαϚϦʔੜ੒ - ௕͍ϝʔϧ͔ΒॏཁͳϙΠϯτ͚ͩΛநग़ https://aws.amazon.com/jp/blogs/messaging-and-targeting/forward-incoming-email-to-an-external-destination/

Slide 26

Slide 26 text

26 ·ͱΊ

Slide 27

Slide 27 text

Copyright © 2015 every, Inc. All rights reserved. 27 ·ͱΊ - ීஈ͋·Γҙࣝͯ͜͠ͳ͔ͬͨϝʔϧͷ಺༰ɾߏ੒ʹ͍ͭͯ஌Εͨྑ͍ػձʹͳͬ ͨʂ - ը૾΍ಈըͳͲͷఴ෇ϑΝΠϧ͕ͲͷΑ͏ʹૹΒΕ͍ͯΔͷֶ͔Μͩ - ͲͷΑ͏ʹͳΓ͢·͠ରࡦ͕ߦΘΕ͍ͯΔͷ͔Λϝʔϧϔομʔ͔ΒֶΜͩ͜ͱͰɺ ϝʔϧΛసૹ΍ฦ৴͢ΔࡍʹඞཁͳॲཧΛߟ͑Δ͖͔͚ͬʹͳͬͨ - GoΛ࢖͍ͳ͕ΒखΛಈֶ͔ͯ͠΂Δͷָ͍͠ - ໘ന͔ͬͨษڧ಺༰ͳͲ͋Γ·ͨ͠Βڭ͍͑ͯͩ͘͞ʂ

Slide 28

Slide 28 text

No content