SMTP with telnet and attchement?

Posted on 2003-12-02
Last Modified: 2007-11-27
i am a beginer.How can i send email by telnet and i want to attach files too when sending emails, can you tell me how can do this? Will you please suggest some softwares for sending emails with attachements by telnet?
Question by:baburkhan
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
  • 2
  • +1

Expert Comment

ID: 9859973
What is your mail server environement? UNIX, then the old standard PINE would fit your needs.

Author Comment

ID: 9861522
it is windows 98 and XP not unix. ummm let me tell you in detail i have an attachment, want to send it by telnet having features like i can write a message and change any data or can you tell me any good software for that or should i write telnet commands in a text and pipe them through netcat, but i dont know the procedure to attach the file (i know sending email messages by telnet at beginners level).

Expert Comment

ID: 9862971
SMTP mail commands (telnet via port 25)

    mail from:<>
    rcpt to:<>
    From: "Bubba Joe" <>
    To: <>
    Subject: Message Text Here
    "Message body"

In order to send attachments via telnet you would have to include the base64 text of your attachment after the subject and prior to the . on a line by itself but this would not be pretty. For example, a small JPEG image might look like this inserted:

Content-Type: image/jpeg; name="image001.jpg"
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename="image001.jpg"
-- lines of base64 encoded image here
-- lines of base64 encoded image here
-- lines of base64 encoded image here
-- lines of base64 encoded image here
-- lines of base64 encoded image here
-- lines of base64 encoded image here
-- lines of base64 encoded image here
-- lines of base64 encoded image here
-- lines of base64 encoded image here
-- lines of base64 encoded image here

These lines will continue for the length of the attachment, not pretty.

Hope this helps.
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!


Author Comment

ID: 9865917
thanks but i want to know more about it. how can i encode my attachement in base64 , i tried to use mpack.exe to do so but i am not familiar with it , moreover can you tell me any software for this which asks me things, connect to telnel itself and send the email.
LVL 37

Expert Comment

ID: 9879878
.exe? baburkhan, what do you want to do? to send junk mails or learn for writing your own email client... ;-))
LVL 37

Expert Comment

ID: 9879897
well, if you dont want to know about base64 encoding in detail, just want to learn a way to send your attachment with telnet, i can show you a method i did successfully.

Author Comment

ID: 9882773
i want to make my own email client , mpack.exe i used to encode attachements in base64, but i dont know how to use this. well i can send emails without attachement now but please help me more with attachements , thanks.
LVL 37

Expert Comment

ID: 9882892
just forget mpack.exe if you dont know how to use it. following my instructions, you can easily get the encoded text of your specific file with well-known email client - Outlook Express.

write a simple or even empty email with the file you want to attach in OE6, save it into the draft folder, save the message to a .eml file, then use notepad to open this .eml file, you may see the encoded attachment is already there, merge it with other parts of email you already edited.

as for understanding base64 encoding, refer the following:

How Base64 Encoding Works

hope it helps,

Accepted Solution

waybadmojo earned 105 total points
ID: 9894967
Using mpack should be fairly straightforward:

The program is activated with:

      mpack [options] -o outputfile inputfile

The most common options are:

     -s subject
     -d descriptionfile
          Include the contents of the file description in an
          introductory section at the beginning of the first
          generated message.

     -c content-type
          Label the included file as being of MIME type
          content-type, which must be a subtype of application,
          audio, image, or video.

     -o outputfile
          Write the generated message to the file outputfile.

For example, to create a mail-ready message with subject of "Test Message" and the attachment program.exe Base-64 encoded in the contents, use the command line:

mpack -s "Test Message" -d message.txt -c application -o program.b64 program.exe

Afterwards, you will have a file named program.b64 which looks like the following:

Message-ID: <??????????@unknownpc>
Mime-Version: 1.0
Subject: Test Message
Content-Type: multipart/mixed; boundary="-"

This is a MIME encoded message.  Decode it with "munpack"
or any other MIME reading software.  Mpack/munpack is available
via anonymous FTP in

The contents of the file message.txt will be inserted here

Content-Type: application/octet-stream; name="program.exe"
Content-Transfer-Encoding: base64
Content-Disposition: inline; filename="program.exe"
Content-MD5: <Base64 encoding of Program.exe will be inserted here>

Hope this helps, and please use your newfound SMTP superpowers only for good!
LVL 37

Expert Comment

ID: 10054369
baburkhan, any feedback please?

Featured Post

MS Dynamics Made Instantly Simpler

Make Your Microsoft Dynamics Investment Count  & Drastically Decrease Training Time by Providing Intuitive Step-By-Step WalkThru Tutorials.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
hmailserver thunderbird slow to send/receive messages 2 176
MailChimp: avoiding the 2,000 email limit 7 118
smtp c source code 7 134
Email accounts in Outlook owa 4 46
Today, security is a big concern in an organization to prevent sensitive data leakage. In Outlook you can secure your Outlook items (emails, calendars, contacts and other stuff) using various techniques like by marking item as private, or you can pu…
Explore the encryption capabilities built into Google Apps and how these features can help you meet privacy policy and regulatory compliance, but are not a full solution. Understand and compare the most popular email encryption services for Google A…
Internet Business Fax to Email Made Easy - With eFax Corporate (, you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

710 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question