Solved

Can i send an attatchment with sendmail?

Posted on 1998-03-17
6
225 Views
Last Modified: 2013-12-23
Hello Expert,

Can i send an attatchment with sendmail?
Thanks

cwc
0
Comment
Question by:cwc061097
[X]
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
6 Comments
 
LVL 1

Expert Comment

by:zonker031798
ID: 1583194
It would help if you could specify (a) what OS you're
using (b) what version of sendmail you're running  and
(c) whether the solution to your problem can involve a MUA
or not.
0
 
LVL 3

Expert Comment

by:elfie
ID: 1583195
Isn't sendmail the "lowlevel"  program that takes care of the actual sending/re-routing of the mails? I thjough it depends which end-user mailsystem you are using (eg. elm, openmail, mail, ...)

0
 
LVL 1

Accepted Solution

by:
dirge earned 100 total points
ID: 1583196
I assume you want a command line solution. You will need at least uuencode, which comes with most Unix distributions, anyway.

The simplest, with no message, would be

uuencode filename filename | sendmail user@domain.com

With a message, it's a bit different. First create a file "msgfile" with the message you want to send, making sure you put at least one blank line after the message, then

uuncode filename filename >> msgfile
sendmail user@domain.com <<msgfile

You may of course, write this into a script or use some other more efficient method, but the basic idea should remain the same.

Here's a sample quick-and-dirty script ("sendattach"):

-------------------------------
#!/bin/bash

msg=`cat`
to=$1
subject=$2
attach=$3
file=`uuencode $attach $attach`
sendmail $to <<END
From: your@address.com
Subject: $subject
To: $to

$msg

$file
END

-------------------------------

Replace your@address.com with your address, of course, or remove the entire From: line to use your default address. Don't forget to chmod +x sendattach. Launch using something like

sendattach recipient@domain.com "This is a test" someimage.gif

Type in message, and press Control-D.

Hope this helps!
0
Independent Software Vendors: 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

by:cwc061097
ID: 1583197
Thanks Dirge for your help
Can u also make a sample script that i can use with perl 5
Thanks again

CWC
0
 
LVL 1

Expert Comment

by:dirge
ID: 1583198
Hi. Thanks for the points!

You'd probably be better off using the MIME-tools Perl modules. The "mimesend" example should be a great starting point. You could even use it as-is in many cases.

You can get MIME-tools from CPAN:

http://www.perl.com/CPAN-local/modules/by-module/MIME/MIME-tools-4.116.tar.gz

Leave a message here or email me at dirge@iquill.net if you need more help.

-dirge
0
 

Author Comment

by:cwc061097
ID: 1583199
Hi Dirge
Thanks for the tip

CWC
0

Featured Post

Free learning courses: Active Directory Deep Dive

Get a firm grasp on your IT environment when you learn Active Directory best practices with Veeam! Watch all, or choose any amount, of this three-part webinar series to improve your skills. From the basics to virtualization and backup, we got you covered.

Question has a verified solution.

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

If you're not part of the solution, you're part of the problem.   Tips on how to secure IoT devices, even the dumbest ones, so they can't be used as part of a DDoS botnet.  Use PRTG Network Monitor as one of the building blocks, to detect unusual…
Most of the applications these days are on Cloud. Cloud is ubiquitous with many service providers in the market. Since it has many benefits such as cost reduction, software updates, remote access, disaster recovery and much more.
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
If you're a developer or IT admin, you’re probably tasked with managing multiple websites, servers, applications, and levels of security on a daily basis. While this can be extremely time consuming, it can also be frustrating when systems aren't wor…

724 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