IT |
気になる、記になる… |
Apple、10月に新型iPadと新型Macの発表イベントを開催へ |
https://taisy0.com/2022/08/22/160346.html
|
apple |
2022-08-21 22:32:11 |
IT |
ITmedia 総合記事一覧 |
[ITmedia ビジネスオンライン] 北海道の”保育園”に首都圏から家族連れが殺到 人口3500人の過疎町に何が? |
https://www.itmedia.co.jp/business/articles/2208/15/news062.html
|
itmedia |
2022-08-22 07:30:00 |
IT |
ITmedia 総合記事一覧 |
[ITmedia エグゼクティブ] トランスフォーメーションの羅針盤となるシナリオプランニングの重要性と活用手法 |
https://mag.executive.itmedia.co.jp/executive/articles/2208/22/news018.html
|
itmedia |
2022-08-22 07:09:00 |
python |
Pythonタグが付けられた新着投稿 - Qiita |
Pythonでかな漢字変換 mozcpy の紹介 |
https://qiita.com/yukinoi/items/000f6fe4560799378dc0
|
mozcpy |
2022-08-22 07:18:07 |
技術ブログ |
Developers.IO |
エンジニアだけどドイツに移住してみた |
https://dev.classmethod.jp/articles/immigrate-to-germany/
|
gutentag |
2022-08-21 22:00:38 |
海外TECH |
DEV Community |
From Java 8 to Kotlin, Clojure and Java 17 |
https://dev.to/jorgetovar621/from-java-8-to-java-11-kotlin-and-clojure-5384
|
From Java to Kotlin Clojure and Java Clojure DaysOfCodeClojure implementation No objects no sealed classes no inheritance Just pure functions with immutable data structures Pending article explaining the differences and principles of the languages used in the book parser example |
2022-08-21 22:41:00 |
海外TECH |
DEV Community |
Sending E-mails with Go. |
https://dev.to/salemzii/sending-e-mails-with-go-ff0
|
Sending E mails with Go Sending email notifications are essential for effective communication between users and service providers Beneath this notable piece of technology lies several layers of abstractions which might require more than a blog post to have a clear or complete idea of which in retrospect isn t the aim of this post In this short article i will quickly try to uncover some issues i faced whilst trying to implement the email notifications for a service i was building at work By default using the standard SMTP package provided by golang i e net smtp suffices for most use cases but depending on the Email service provider you re using you might experience some bottle necks using the smtp package We use Webmail where i work and the first time i tried using net smtp with it i experienced some irregularities for instance my client was successfully able to authenticate my credentials and send the mail message using the smtp SendMail method with the sample code below package mailsimport log net smtp var From mail os Getenv FROM MAIL Mail password os Getenv MAIL PASSWORD SMTP Host os Getenv HOST func SendMail msg string recipient string Message message byte This is a test email message Authentication auth smtp PlainAuth From mail Mail password SMTP Host fmt Println auth Sending email if err smtp SendMail fmt Sprintf s d SMTP Host auth From mail recipient message err nil log Printf Error sending mail v err return log Println Email Sent Successfully but on the recieving end no mails were delivered After series of relentless searching for a reasonable explanations to why i was experiencing such i got to learn some email service providers like the one i used preferred sending mails over port requiring an ssl connection from the very beginning without starttls as compared to the standard which uses plain TCP to send the mail traffic to the server with subsequent calls using Starttls There s been argument over these ports for a long time but generally sending mails over port is more recommended as it is provides a much secured transmission layer compared to port How these protocols are implemented depends mainly on the service providers you re using and the network protocol they choose for each port for example Gmail uses SSL for the SMTP server on port and TLS for port how SSL and TLS are implemented and used for secure data tranmission on the internet is beyond the scope of this article but you can read more about these protocols here Luckily i found this github gist which solved the problem we ve been trying to figure out I refactored the code to fit my use case but you can get the actual solution from the gist link above now unto the actual code package mainimport crypto tls fmt log net mail net smtp os sync var From mail os Getenv FROM MAIL Mail password os Getenv MAIL PASSWORD SMTP Host os Getenv HOST Mail subject string Mail body string from mail Address auth smtp Auth tlsconfig tls Config mailwg sync WaitGroup type Container struct m sync Mutex Headers map string string func NewContainer Container return amp Container Headers make map string string func main SendMails subject article message string testuser gmail com testuser gmail com func init from amp mail Address Name Test mail Address From mail auth smtp PlainAuth From mail Mail password SMTP Host tlsconfig amp tls Config InsecureSkipVerify true ServerName SMTP Host func SendSSLMail subject msg string recipient string to mail Address Name Address recipient Mail subject subject Mail body msg initialize new container object container NewContainer call mutex lock to avoid multiple writes to one header instance from running goroutines container m Lock container Headers From from String container Headers To to String container Headers Subject Mail subject unlock mutex after function returns defer container m Unlock Setup message message for k v range container Headers message fmt Sprintf s s r n k v message r n Mail body conn err tls Dial tcp fmt Sprintf s d SMTP Host tlsconfig if err nil log Printf Error sending mail v err return c err smtp NewClient conn SMTP Host if err nil log Printf Error sending mail v err return Auth if err c Auth auth err nil log Printf Error sending mail v err return To amp amp From if err c Mail from Address err nil log Printf Error sending mail v err return if err c Rcpt to Address err nil log Printf Error sending mail v err return Data w err c Data if err nil log Printf Error sending mail v err return err w Write byte message if err nil log Printf Error sending mail v err return err w Close if err nil log Printf Error sending mail v err return if err c Quit err nil return Concurrently sending mails to multiple recipientsfunc SendMails subject msg string recipients string mailwg Add len recipients for v range recipients go func recipient string defer mailwg Done SendSSLMail subject msg recipient v mailwg Wait In the code above we declared variables to hold our smtp credentials then we declared a struct named Container which basically contains a mutex m field that essentially allows us to avoid Race Conditions i e when different threads goroutines try to access and mutate the state of a resource at the same time this is to lock the Headers field which is the actual email header containing meta data of each email to be sent The init function allows us to initialize some of the resource to be used before the function is called you can see we initialize the auth variable with our mail credentials which returns an smtp Auth type we then move further to set up tlsconfig which basically determines how the client and server should handle data transfer The SendMails function lets us send mails concurrently to avoid calling the SendSSLMail function for each number of recipients we want to distribute the mail to I believe the SendSSLMail function body is quite straight forward and doesn t require much explanation as at the time of publishing this article this service is being used so i m pretty sure it is stable enough to be used by anyone ConclusionSending mails are very essential to the growth of any business as they allow direct communication with the customers Knowing how to effectively build stable email services is quitessential to every software developer out there I hope this article helps solve any challenge you might encounter while writing a mail services with Go Let me know what you think about this article and possibly any amendments that could be made to improve it s user experience thanks for reading and have a great time |
2022-08-21 22:05:57 |
Apple |
AppleInsider - Frontpage News |
Apple TV+ scraps 'My Glory Was I Had Such Friends' after Jennifer Garner leaves project |
https://appleinsider.com/articles/22/08/21/apple-tv-scraps-my-glory-was-i-had-such-friends-after-jennifer-garner-leaves-project?utm_medium=rss
|
Apple TV scraps x My Glory Was I Had Such Friends x after Jennifer Garner leaves projectAn in production Apple TV limited series My Glory Was I Had Such Friends is being scrapped a report claims after star Jennifer Garner exited the project The limited series based on the Amy Silverstein memoir of the same title was initially acquired by Apple in in a straight to series order After an extended development period Garner has now pulled out of the project entirely a move which has reportedly killed the project on Apple s streaming platform Sources of Deadline say scheduling issues forced Garner into leaving the show though none of the parties involved have officially commented on the change With Garner out Apple has apparently decided not to proceed with it either Read more |
2022-08-21 22:42:04 |
ニュース |
BBC News - Home |
Ukraine war: Allies seek more security at Zaporizhzhia nuclear plant |
https://www.bbc.co.uk/news/world-europe-62626763?at_medium=RSS&at_campaign=KARANGA
|
ukraine |
2022-08-21 22:06:24 |
ニュース |
BBC News - Home |
The Papers: 'Debt crisis fears', and Fury's knife crime plea |
https://www.bbc.co.uk/news/blogs-the-papers-62627788?at_medium=RSS&at_campaign=KARANGA
|
tyson |
2022-08-21 22:44:06 |
ニュース |
BBC News - Home |
Alan Shearer column: Ex-Newcastle captain says his old side could be 'best of rest' |
https://www.bbc.co.uk/sport/football/62627652?at_medium=RSS&at_campaign=KARANGA
|
Alan Shearer column Ex Newcastle captain says his old side could be x best of rest x Match of the Day pundit Alan Shearer says these are exciting times for Newcastle and that they could be the best of the rest in the Premier League this season |
2022-08-21 22:09:33 |
ニュース |
BBC News - Home |
European Championships Munich 2022: Great Britain win 60 medals to finish second in medal table |
https://www.bbc.co.uk/sport/62627871?at_medium=RSS&at_campaign=KARANGA
|
European Championships Munich Great Britain win medals to finish second in medal tableGreat Britain finish with medals at the European Championships while a further are won at the European Aquatics Championships |
2022-08-21 22:12:40 |
北海道 |
北海道新聞 |
東国幹・衆院議員、旧統一教会と接点 会長職の団体、会員の県議が旭川で講演 |
https://www.hokkaido-np.co.jp/article/720374/
|
統一教会 |
2022-08-22 07:27:32 |
北海道 |
北海道新聞 |
鈴木10号、3安打1打点 ブルワーズ戦 |
https://www.hokkaido-np.co.jp/article/720396/
|
打点 |
2022-08-22 07:23:00 |
北海道 |
北海道新聞 |
ドイツ首相隣で裸の訴え 女性ら「ロシア産ガス禁輸を」 |
https://www.hokkaido-np.co.jp/article/720395/
|
政府機関 |
2022-08-22 07:03:00 |
IT |
週刊アスキー |
疾患リスクなど6500項目以上解析 一般用全ゲノム解析遺伝子検査キット |
https://weekly.ascii.jp/elem/000/004/101/4101740/
|
genelifewgs |
2022-08-22 07:30:00 |
コメント
コメントを投稿