Correct email format for Email with Plain, HTML and an Attachment in SMTP?

后端 未结 2 1280
北恋
北恋 2021-01-06 02:19

The Problem:

I tried to copy the SMTP based headers/emails used by yahoo and hotmail and send them over Telnet, but the email I get does not display

2条回答
  •  耶瑟儿~
    2021-01-06 02:25

    I cleaned up the multipart boundary specifiers and got this, which works for me on my server (I've left off the SMTP commands here):

    From: "Edited Out"  
    To: "Edited Out"  
    Subject: Testing 4
    MIME-Version: 1.0
    Content-Type: multipart/alternative;
      boundary="boundary-type-1234567892-alt"
    
    --boundary-type-1234567892-alt
    Content-Type: text/plain; charset="iso-8859-1"
    Content-Transfer-Encoding: quoted-printable
    
    
    Testing the text to see if it works!
    
    --boundary-type-1234567892-alt
    Content-Type: text/html; charset="iso-8859-1"
    Content-Transfer-Encoding: quoted-printable
    
    
    Does this actually work?
    
    --boundary-type-1234567892-alt
    Content-Transfer-Encoding: base64
    Content-Type: text/plain;name="Here2.txt"
    Content-Disposition: attachment;filename="Here2.txt"
    
    KiAxMyBGRVRDSCAoQk9EWVtURVhUXSB7NjU5fQ0KLS1fZjZiM2I1ZWUtMjA3YS00ZDdiLTg0NTgtNDY5YmVlNDkxOGRhXw0    KQ29udGVudC1UeXBlOiB0ZXh0L3BsYWluOyBjaGFyc2V0PSJpc28tODg1OS0xIg0KQ29udGVudC1UcmFuc2Zlci1FbmNvZG    luZzogcXVvdGVkLXByaW50YWJsZQ0KDQoNCkp1c3Qgc2VlaW5nIHdoYXQgdGhpcyBhY3R1
    YWxseSBjb250YWlucyEgCQkgCSAgIAkJICA9DQoNCi0tX2Y2YjNiNWVlLTIwN2EtNGQ3Yi04NDU4LTQ2OWJlZTQ5MThkYV8    NCkNvbnRlbnQtVHlwZTogdGV4dC9odG1sOyBjaGFyc2V0PSJpc28tODg1OS0xIg0KQ29udGVudC1UcmFuc2Zlci1FbmNvZG    luZzogcXVvdGVkLXByaW50YWJsZQ0KDQo8aHRtbD4NCjxoZWFkPg0KPHN0eWxlPjwhLS0N
    Ci5obW1lc3NhZ2UgUA0Kew0KbWFyZ2luOjBweD0zQg0KcGFkZGluZzowcHgNCn0NCmJvZHkuaG1tZXNzYWdlDQp7DQpmb25    0LXNpemU6IDEwcHQ9M0INCmZvbnQtZmFtaWx5OlRhaG9tYQ0KfQ0KLS0+PC9zdHlsZT48L2hlYWQ+DQo8Ym9keSBjbGFzcz    0zRCdobW1lc3NhZ2UnPjxkaXYgZGlyPTNEJ2x0cic+DQpKdXN0IHNlZWluZyB3aGF0IHRo
    aXMgYWN0dWFsbHkgY29udGFpbnMhIAkJIAkgICAJCSAgPC9kaXY+PC9ib2R5Pg0KPC9odG1sPj0NCg0KLS1fZjZiM2I1ZWU    tMjA3YS00ZDdiLTg0NTgtNDY5YmVlNDkxOGRhXy0tDQopDQpmbHlubmNvbXB1dGVyIE9LIEZFVENIIGNvbXBsZXRlZA
    
    
    --boundary-type-1234567890-alt--
    

    The boundary specifier in a multipart email is any arbitrary text that's not likely to appear in the email body/attachments. When it shows up with two dashes in front, that specifies the beginning of new part (including the very first part. When it shows up with two dashes at the beginning and end, that specifies the end of the mail.

    Your original mail had this "end boundary" marker in the middle of the mail (right after Does this actually work?), and had two different boundary markers (--boundary-type-1234567890 and --boundary-type-1234567892-alt). That explains why the attachment was left off.

提交回复
热议问题