LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
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.

Notices

Reply
 
Search this Thread
Old 03-12-2003, 11:26 PM   #1
jchristman
Member
 
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 "from@from.com" "sendto@sendto.com"

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
unSpawn
Moderator
 
Registered: May 2001
Posts: 27,564
Blog Entries: 54

Rep: Reputation: 2927Reputation: 2927Reputation: 2927Reputation: 2927Reputation: 2927Reputation: 2927Reputation: 2927Reputation: 2927Reputation: 2927Reputation: 2927Reputation: 2927
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
AltF4
Member
 
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.


Code:
## from: http://www.experts-exchange.com/Prog..._20208667.html

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'
);

$msg->attach(
   Type =>'TEXT',
   Data =>"Dear $fields{'membersname'},\n\nTEST MESSAGE\n"
);

foreach my $file ( qw(1.gif 2.gif 3.gif) ) {
   $msg->attach(
       Type => 'image/gif',
       Path => "../public/images/$file",
       Filename => $file,
       Disposition => 'attachment'
   );
}
$msg->send;
 
Old 03-13-2003, 05:22 PM   #4
jchristman
Member
 
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
turnip
Member
 
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.
 
  


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
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


All times are GMT -5. The time now is 08:40 AM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration