LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   command line sendmail (https://www.linuxquestions.org/questions/linux-software-2/command-line-sendmail-49536/)

jchristman 03-12-2003 10:26 PM

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.

unSpawn 03-12-2003 10:55 PM

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

AltF4 03-13-2003 06:12 AM

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;


jchristman 03-13-2003 04:22 PM

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.

turnip 03-13-2003 05:33 PM

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.


All times are GMT -5. The time now is 03:25 AM.