Perl & Sendmail

Hi ! I've created a temp-text file which I want to send to somebody. How do I do tis with sendmail ? Is there a command like sendmail to xy@xy.com from xy@xy.com content tempfile.tmp

regards
ItsMe
ItsMeAsked:
Who is Participating?

Improve company productivity with a Business Account.Sign Up

x
 
lambdaConnect With a Mentor Commented:
I think it's not possible to send the file as attachment using sendmail.
But you can send it like this:


open (MAIL_MSG, "path/to/MailMsg.txt");
while (<MAIL_MSG>)
{
      $body .= $_;
}
close (MAIL_MSG);

open(MAIL, "|/usr/sbin/sendmail -t ") || return 1;
 select (MAIL);

 print  MAIL "To\: $To_email\n";
 print  MAIL "From\: Name <abc\@def.com>\n";
 print  MAIL "Subject\: text attached\n";

 print  MAIL "\n$body\n";

 close(MAIL);
0
 
lambdaCommented:
U can remove the line
select (MAIL);

from the code, it is not actually required


£.
0
 
ItsMeAuthor Commented:
Hi !
what does the | means ?

regards
ItsMe
0
 
ozoCommented:
perldoc -f open
0
 
lambdaCommented:
The '|' sends the output to the sendmail program.
For more details, you can type what ozo suggested, at the prompt.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.