CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Beginner:
How to make script send "contents" of a text file

 



prsnlty
Deleted

Apr 7, 2000, 7:40 PM

Post #1 of 3 (637 views)
How to make script send "contents" of a text file Can't Post

Hello :-)
First let me explain that I have a script I had custom written for me. I have modified it to send an auto-response via email to the person filling out our form. The problem I'm having is that it sends the correct text file but in name only. It does not send the contents of the file in the body of the email as I had hoped it would the only thing in the body is the file name: "LFS!_conformation.txt".
My question: What am I missing here? Everything works like a dream with this one exception. This is the portion of the script code to send the mail:
# tell-a-friend
sub mailto {

if ($to) {
open (MAIL, "|$sendmail -t") | | &error('sendmail');

# open (MAIL, ">&STDOUT");
# print MAIL "Content-Type: text/html\n\n";
# print MAIL "<HTML><PRE>\n";

print MAIL "To: $to\n";
print MAIL "From: $from\n";
print MAIL "Date: $date\n";
print MAIL "Subject: $contents{'LETTERID'} \-\- $contents{'SEND'}\n";
print MAIL "\n";
@out = split(/\\n/, $contents{'CONFORMATION'});
foreach $out (@out) {
print MAIL $out;
}
print MAIL "\n\n";

# print MAIL "</PRE></HTML>\n";

close (MAIL);
}
}



Cure
User

Apr 7, 2000, 8:16 PM

Post #2 of 3 (637 views)
Re: How to make script send "contents" of a text file [In reply to] Can't Post

Hi

This will work for you.

$db = 'LFS!_conformation.txt';

open(FILE, "$db") or die("$!");

while (<FILE> ) {

push @cure, $_;

}

close(FILE);

$to='you@yahoo.com';
$from='me@yahoo.com';
open(MAIL, "|$sendmail -t") or die("$!");
print MAIL <<"END_OF_MAIL";
To: $toname
From: $fromname
Subject: perl
Content-Type: text/html

@cure
END_OF_MAIL
close(MAIL);


Cure

[This message has been edited by Cure (edited 04-07-2000).]


prsnlty
Deleted

Apr 7, 2000, 9:02 PM

Post #3 of 3 (637 views)
Re: How to make script send "contents" of a text file [In reply to] Can't Post

Hi and thank you :-)
I do have a question though. Some of the information in the original portion of the script that I pasted here are nessesary. Such as the subject, to and from. The reason is that these are being taken from the form page. The item in the subject line is an actual order or tracking number also generated by this script. The script also sends me the order at the same time as the response e-mail goes out along with the same subject line information. If I change the to and from lines I'm afraid it will create a problem. Would you like to look at the script? I found that not having the information below that it doesn't work correctly. The mailto variable is being pulled off the webpage as well as the subject line which is most important, and to is also coming from that same page.
To see what I'm talking about you can view the source of the page here: http://www.allletters.com/Holiday_Letters/LFS1.shtml

This script does many things at once. This took us months to come up with but I find that now I need to have it automatically send conformation along with the order number. I was doing it all manually and I know there is no way I can do it this year that way. I have custom personalized letters some will be e-mail letters the others are to purchase. I have duplicated the script and renamed for the email letters just so I can use this ones email to send the conformation instead for purchased letters.
I just want you to get an idea what I'm talking about. Since the script is custom and I cannot post the full script for all to see. However I would send it to you. If you would be so kind to view it to be sure I can use the information that you gave me.

Again,
Thank you :-D
Jackie


 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives