• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 255
  • Last Modified:

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
0
ItsMe
Asked:
ItsMe
  • 3
1 Solution
 
lambdaCommented:
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

Featured Post

Receive 1:1 tech help

Solve your biggest tech problems alongside global tech experts with 1:1 help.

  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now