Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Perl & Sendmail

Posted on 2000-04-09
5
Medium Priority
?
251 Views
Last Modified: 2013-12-25
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
Comment
Question by:ItsMe
  • 3
5 Comments
 
LVL 1

Accepted Solution

by:
lambda earned 120 total points
ID: 2699073
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
 
LVL 1

Expert Comment

by:lambda
ID: 2699080
U can remove the line
select (MAIL);

from the code, it is not actually required


£.
0
 

Author Comment

by:ItsMe
ID: 2699921
Hi !
what does the | means ?

regards
ItsMe
0
 
LVL 85

Expert Comment

by:ozo
ID: 2701052
perldoc -f open
0
 
LVL 1

Expert Comment

by:lambda
ID: 2702788
The '|' sends the output to the sendmail program.
For more details, you can type what ozo suggested, at the prompt.
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Making a simple AJAX shopping cart Couple years ago I made my first shopping cart, I used iframe and JavaScript, it was very good at that time, there were no sessions or AJAX, I used cookies on clients machine. Today we have more advanced techno…
I hope you'll find this tutorial useful and interesting. So let's try to extend Tcl with a new package.  For anyone more deeply interested please check out the book "Practical Programming in Tcl and Tk". It's really one of the best written books abo…
Learn the basics of strings in Python: declaration, operations, indices, and slicing. Strings are declared with quotations; for example: s = "string": Strings are immutable.: Strings may be concatenated or multiplied using the addition and multiplic…
Learn the basics of if, else, and elif statements in Python 2.7. Use "if" statements to test a specified condition.: The structure of an if statement is as follows: (CODE) Use "else" statements to allow the execution of an alternative, if the …
Suggested Courses

963 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question