Visit Jeremy's Blog.
Go Back > Forums > Linux Forums > Linux - Software
User Name
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.


  Search this Thread
Old 03-12-2003, 11:26 PM   #1
Registered: Mar 2003
Distribution: Fedora Core 3
Posts: 125

Rep: Reputation: 15
Post command line sendmail

I need help with commandline sendmail.

I want to send an email with an attachment .

I would like to be able to use the Cc: and Bcc: Subject: Body: plus have an attachement sent with the email.

!cat /tmp/testpage.txt | /usr/sbin/sendmail -i -oi -f "" ""

this places the file into the body, but the format gets messed up
how can I send an attachment.

I dont care if I need to use a perl script just so long as I can pass it the from: email To: email and the body then the attachment and a subject line would be nice.

Can anyone help.
Old 03-12-2003, 11:55 PM   #2
Registered: May 2001
Posts: 29,415
Blog Entries: 55

Rep: Reputation: 3598Reputation: 3598Reputation: 3598Reputation: 3598Reputation: 3598Reputation: 3598Reputation: 3598Reputation: 3598Reputation: 3598Reputation: 3598Reputation: 3598
If testpage is plain text and you don't need to interface with sendmail as a requirement you could just: "cat /tmp/testpage.txt | mail -s <subject> -c <cc addr> -b <bcc addr> <to addr>".
Old 03-13-2003, 07:12 AM   #3
Registered: Sep 2002
Location: .at
Distribution: SuSE, Knoppix
Posts: 532

Rep: Reputation: 31
if you really want an attachment you need to get a MUA (Mail User Agent) or a small program (perl with MIME::Lite, etc) to do the job.

sendmail is a MTA (Mail Transfer Agent) and doesn't care for mail content (MIME attachments, etc), but only for delivery.

## from:

use MIME::Lite;

# The rest of script here ...

my $msg = MIME::Lite->new (
   From => $your_email,
   To => $fields{'membersemailaddress'},
   Subject => 'Test Subject',
   Type => 'multipart/mixed'

   Type =>'TEXT',
   Data =>"Dear $fields{'membersname'},\n\nTEST MESSAGE\n"

foreach my $file ( qw(1.gif 2.gif 3.gif) ) {
       Type => 'image/gif',
       Path => "../public/images/$file",
       Filename => $file,
       Disposition => 'attachment'
Old 03-13-2003, 05:22 PM   #4
Registered: Mar 2003
Distribution: Fedora Core 3
Posts: 125

Original Poster
Rep: Reputation: 15
unspawn This is great but it is not quit completely what i need.
I just tried this way and it gives me the subject and the addressing with cc bcc, but it still placed the file into the body of the email and not as an attachment. I would also like to change the from user so it is not just from who is logged in.
Old 03-13-2003, 06:33 PM   #5
Registered: Jul 2002
Posts: 143

Rep: Reputation: 15
you can use metasend and metamail to do what you are looking to do. I havnt tried either yet, but I know they support scripted mail with attachments.


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
Sendmail from the command line Draithon Linux - Newbie 5 04-14-2011 04:57 AM
command-line sendmail dajomu Linux - Software 3 08-24-2005 04:45 AM
Using sendmail in command line Belghouth Mandriva 1 12-08-2004 11:55 AM
sendmail usage in command line Belghouth Slackware 1 12-08-2004 11:55 AM
Sendmail command line examples please. leongoogs Linux - General 2 07-21-2004 09:23 AM > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 03:23 PM.

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