Solved

Can i send an attatchment with sendmail?

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

Can i send an attatchment with sendmail?
Thanks

cwc
0
Comment
Question by:cwc061097
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
Give your grad a cloud of their own!

With up to 8TB of storage, give your favorite graduate their own personal cloud to centralize all their photos, videos and music in one safe place. They can save, sync and share all their stuff, and automatic photo backup helps free up space on their smartphone and tablet.

 

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

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

This is an article about my experiences with remote access to my clients (so that I may serve them) and eventually to my home office system via Radmin Remote Control. I have been using remote access for over 10 years and have been improving my metho…
If your business is like most, chances are you still need to maintain a fax infrastructure for your staff. It’s hard to believe that a communication technology that was thriving in the mid-80s could still be an essential part of your team’s modern I…
After creating this article (http://www.experts-exchange.com/articles/23699/Setup-Mikrotik-routers-with-OSPF.html), I decided to make a video (no audio) to show you how to configure the routers and run some trace routes and pings between the 7 sites…
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.

746 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

Need Help in Real-Time?

Connect with top rated Experts

8 Experts available now in Live!

Get 1:1 Help Now