Search This Blog

Thursday, September 10, 2020

SMTP Telnet

 I was working an issue with a Microsoft Edge Transport server where the content of the email was getting truncated after 6 lines. I was able to create a test and get show the delivery of the message through the Edge server to the destination mailboxes. But My test did not include the attached file of the messages that were failing. as the file was a really small csv I took up the challenge of generating the email with an attachment through a telnet session.

Steps: 

Get the csv attachment.

Generate the mime for the attachment

Modify the text of the telnet session to generate the message

Check the results.


I created a small csv using a text editor 

Company,Address,City,State,Zip

CareWorks Technologies,,Dublin,Ohio,43016

CTG,55 Public Square,Cleveland,Ohio,44113

"State Industrial Products, Inc.",3100 Hamilton Avenue,Cleveland,Ohio,44114

"Finast Supermarkets, Inc.",17000 Rockside Road,Maple Heights,Ohio,44137

Saved it as C:\Users\Lesley\Downloads\Companies.csv

Using Poswershell,

[Convert]::ToBase64String([IO.File]::ReadAllBytes('C:\Users\Lesley\Downloads\Companies.csv'))

I generated the following mime blob...
Q29tcGFueSxBZGRyZXNzLENpdHksU3RhdGUsWmlwDQpDYXJlV29ya3MgVGVjaG5vbG9naWVzLCxEdWJsaW4sT2hpbyw0MzAxNg0KQ1RHLDU1IFB1YmxpYyBTcXVhcmUsQ2xldmVsYW5kLE9oaW8sNDQx
MTMNCiJTdGF0ZSBJbmR1c3RyaWFsIFByb2R1Y3RzLCBJbmMuIiwzMTAwIEhhbWlsdG9uIEF2ZW51ZSxDbGV2ZWxhbmQsT2hpbyw0NDExNA0KIkZpbmFzdCBTdXBlcm1hcmtldHMsIEluYy4iLDE3MDAw
IFJvY2tzaWRlIFJvYWQsTWFwbGUgSGVpZ2h0cyxPaGlvLDQ0MTM3DQo=
I then added that to a telnet session like this...
telnet 10.0.0.10 25
HELO lesley.mycompany.com
MAIL FROM: <lesley@mycompany.com>
RCPT To: <lesleyphillips@yahoo.com>
DATA
subject: TLX21MLC1 : PCC LOADER JOB COMPLETED
MIME-Version: 1.0
Content-Type: multipart/mixed; boundary=border
--border
Content-Type: text/plain
 
A short list of companies I've worked at

-Lesley

--border
Content-Type: application/octet-stream
Content-Transfer-Encoding: base64;
Content-Disposition: attachment;
        filename="Companies.CSV"

Q29tcGFueSxBZGRyZXNzLENpdHksU3RhdGUsWmlwDQpDYXJlV29ya3MgVGVjaG5vbG9naWVzLCxEdWJsaW4sT2hpbyw0MzAxNg0KQ1RHLDU1IFB1YmxpYyBTcXVhcmUsQ2xldmVsYW5kLE9oaW8sNDQx
MTMNCiJTdGF0ZSBJbmR1c3RyaWFsIFByb2R1Y3RzLCBJbmMuIiwzMTAwIEhhbWlsdG9uIEF2ZW51ZSxDbGV2ZWxhbmQsT2hpbyw0NDExNA0KIkZpbmFzdCBTdXBlcm1hcmtldHMsIEluYy4iLDE3MDAw
IFJvY2tzaWRlIFJvYWQsTWFwbGUgSGVpZ2h0cyxPaGlvLDQ0MTM3DQo=
--border--
 
.
 
quit

And, the result...