Skip to main content

Featured

Build docker image from multiple build contexts

Build docker image from multiple build contexts Building a docker image requires specifying a source of truth to include in the image from a local directory or a remote git repository. In the previous version, the docker BuildKit allows users to specify the build context from a single source of truth only. However, the engineers may need to have the context from different locations based on the type of files. For instance, icons, images or other resources that are not included in the same package, including the resource from other docker images. Fortunately, the Docker Buildx toolkit supports multiple build context flag for Docker 1.4. Let's learn how to use this new feature. The following list is a shortcut for jumping into a specific topic handy. What version of Docker is this tutorial targeting? How to specify the version of Dockerfile frontend? Ho

SMTP Client - send mail

目前參照http://www.codeproject.com/KB/IP/CSmtp.aspx?fid=1525693&df=90&mpp=25&noise=3&sort=Position&view=Quick&fr=26所做出來的client端程式可正常運行。

唯獨在附加檔案的部份,一開始測試是讀取8k資料並傳送之,但是用outlook卻都收不到郵件。
由此可推測,是否是單一個section大小過大導致SMTP server拒絕接收郵件資料。

後來根據sample裡面設定的section大小(5k)來傳送,則可正常收到郵件。
故此目前先暫時用5k的section大小來傳遞檔案,以後有空的時候在來研究一下RFC。

Ref:RFC5246RFC2487

Mail Format:(以下每一段建立後皆立即送出,括弧內或是藍色文字為註解)
Mail From:<SP>UserName<MailAddress><CRLF>
RCPT To:<SP>UserName<MailAddress><CRLF>(包含副本跟密件副本的收件人)
DATA (以下為郵件本體)
Header Content Start
Date:<SP>day<SP>month<SP>year<SP>hour:min:sec<SP>zone<CRLF>
From:<SP>UserName<MailAddress><CRLF>
X-Mailer:<SP>X-Mailer<CRLF>
Reply-To:<SP>MailAddress<CRLF>
X-Priority:<SP>Priority<CRLF>
To:UserName<MailAddress>,UserName<MailAddress>,...<CRLF>
Cc:UserName<MailAddress>,UserName<MailAddress>,...<CRLF>
Bcc:UserName<MailAddress>,UserName<MailAddress>,...<CRLF>
Subject:<SP>Subject<CRLF>
MIME-Version:<SP>version<CRLF>
(無附加檔)
Content-type: text/plain; charset=US-ASCII<CRLF>
Content-Transfer-Encoding: 7bit<CRLF><CRLF>
(*有附加檔,BOUNDARY_TEXT自定,網路上範例都將內容寫的很長)
Content-Type: multipart/mixed; boundary="BOUNDARY_TEXT"<CRLF><CRLF>
--BOUNDARY_TEXT<CRLF>
Content-type: text/plain; charset=US-ASCII<CRLF>
Content-Transfer-Encoding: 7bit<CRLF><CRLF>
Header Content End
Message body
<CRLF>(每一行資料後面都要有crlf,但測試只有lf也是可以的。這邊郵件內容長度無限制,最好是一次送出)
(加入附加檔內容)
--BOUNDARY_TEXT<CRLF>
Content-Type: application/x-msdownload; name="FileName.ext"<CRLF>
Content-Transfer-Encoding: base64<CRLF>
Content-Disposition: attachment; filename="FileName.ext"<CRLF><CRLF>

(由Base64加密過的檔案內容,每一送出的Section大小不可超過6k)
(重覆做*,到所有檔案傳完為止)
--BOUNDARY_TEXT--(附加檔結束)
<CRLF>.<CRLF> (郵件內容傳送完畢)
QUIT<CRLF> (離開)

Comments

Popular Posts