LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 11-25-2009, 05:00 AM   #1
antanas
LQ Newbie
 
Registered: Oct 2006
Posts: 18

Rep: Reputation: 0
Sending mail attachment via Sendmail


Hi,

researching this for a day already, but can't seem to get it to work.
Trying to write a simple script that would send an attachment from the box to windows recipients.

script currently looks like this:
-------------------------------------------------
#!/usr/bin/ksh

# send del to DW and other recipients
echo "Please put in a DEL name:"
read FILENAME

uuencode $FILENAME $FILENAME | sendmail -v -f sender@company.com -t recipient@company.com < header
-------------------------------------------------

The header looks like this:
-------------------------------------------------
To: recipient@company.com
From: sender@company.com
Subject: Please find the file attached
-------------------------------------------------

The problem i'm having is header fields get populated but no file gets attached.

If i don't use the header file/data like so:

uuencode $DELNAME $DELNAME | sendmail -f sender@company.com -t recipient@company.com

The file gets attached but header information (to: , subject: ..) and there's no body message.

If i don't use the uuencode feature and just use this command:
sendmail -f ender@company.com -t recipient@company.com < FILENAME

the file name contents just appear in the body of the message instead of attaching it to an email.


Help would be greatly appreciated.

Last edited by antanas; 11-25-2009 at 05:01 AM.
 
Old 11-25-2009, 05:07 AM   #2
centosboy
Senior Member
 
Registered: May 2009
Location: london
Distribution: centos5
Posts: 1,137

Rep: Reputation: 116Reputation: 116
Quote:
Originally Posted by antanas View Post
Hi,

researching this for a day already, but can't seem to get it to work.
Trying to write a simple script that would send an attachment from the box to windows recipients.

script currently looks like this:
-------------------------------------------------
#!/usr/bin/ksh

# send del to DW and other recipients
echo "Please put in a DEL name:"
read FILENAME

uuencode $FILENAME $FILENAME | sendmail -v -f sender@company.com -t recipient@company.com < header
-------------------------------------------------

The header looks like this:
-------------------------------------------------
To: recipient@company.com
From: sender@company.com
Subject: Please find the file attached
-------------------------------------------------

The problem i'm having is header fields get populated but no file gets attached.

If i don't use the header file/data like so:

uuencode $DELNAME $DELNAME | sendmail -f sender@company.com -t recipient@company.com

The file gets attached but header information (to: , subject: ..) and there's no body message.

If i don't use the uuencode feature and just use this command:
sendmail -f ender@company.com -t recipient@company.com < FILENAME

the file name contents just appear in the body of the message instead of attaching it to an email.


Help would be greatly appreciated.
you may have to use a simple perl module to get this exactly right.
there is one called mime lite that is pretty easy to set up.

Code:
http://search.cpan.org/~rjbs/MIME-Lite-3.027/lib/MIME/Lite.pm
if not, mutt can do this.


Code:
mutt -a
 
Old 11-25-2009, 05:18 AM   #3
timmeke
Senior Member
 
Registered: Nov 2005
Location: Belgium
Distribution: Red Hat, Fedora
Posts: 1,515

Rep: Reputation: 61
Nail could also work and connect to any SMTP server. similar -a option for attachments
 
Old 11-25-2009, 05:24 AM   #4
antanas
LQ Newbie
 
Registered: Oct 2006
Posts: 18

Original Poster
Rep: Reputation: 0
MIME is not installed on the box and im afraid i do not have option to install it. mutt is not there as well. tried mailx but ending up with similar problem.

Nail is not there as well.
 
Old 11-25-2009, 05:39 AM   #5
timmeke
Senior Member
 
Registered: Nov 2005
Location: Belgium
Distribution: Red Hat, Fedora
Posts: 1,515

Rep: Reputation: 61
So you can mess with the sendmail config but not install small tools? Why is that?
 
Old 11-25-2009, 05:42 AM   #6
antanas
LQ Newbie
 
Registered: Oct 2006
Posts: 18

Original Poster
Rep: Reputation: 0
I don't mess with sendmail config file, just input the header before sending.
found out that SHAR tool can be of some use and it's installed on the box. trying to figure it out.
Anyone used it for sending attachments with sendmail?
 
Old 11-25-2009, 06:54 PM   #7
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,419

Rep: Reputation: 2785Reputation: 2785Reputation: 2785Reputation: 2785Reputation: 2785Reputation: 2785Reputation: 2785Reputation: 2785Reputation: 2785Reputation: 2785Reputation: 2785
Try post #5 http://www.unix.com/how-do-i-send-em...ment-body.html
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Gmail and yahoo mail fail sending with attachment using squid 2.5 stable 7 proxy daniel314 Linux - Networking 2 10-20-2009 03:36 PM
Sendmail (mailserver) -- sending mail with the mail command -- doesn't work :-( carolinevdh Linux - Server 1 08-13-2009 10:43 PM
Sendmail not sending mail tarheel92x Linux - Server 8 10-27-2006 05:44 AM
Sending mail without sendmail geomonap Linux - Security 2 12-21-2004 02:32 AM
Sending file attachment with Sendmail aurelio26 Linux - Newbie 2 09-17-2004 01:36 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 12:41 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration