Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

(Hopefully) last mail problem

Status
Not open for further replies.

JimJx

Technical User
Feb 16, 2001
202
US
Hi again all,

I am trying to write a postcard script for a friends site, and am running into a problem that has me scratching my head......

He wants the sender to be notified when the card is picked up, and I can get everything to work fine, except the confirmation email will not send. I have 2 other places in the script that mail is sent just fine, and I am using the same basic code to send this one.

I don't get any errors on the server logs, it just doesn't send.

The &print_html; that is right after the &notify; executes perfectly, it is just like it isn't calling the &notify sub at all.....

Any ideas/advice will be greatly appreciated.
Jim

Code:
#######################################################
sub pickup_card {
#Open card.list file
open (DATABASE, "$cardlist") || &CgiDie ("I am sorry, but I was not able to open the 
data file.");
flock (DATABASE, 2);
#Assign database to list array
	@list = <DATABASE>;
flock (DATABASE, 8);
close (DATABASE);

#Split array into scalar variables 
foreach $list (@list) {
($userid, $sender, $senderemail, $message, $name, $notify, $image, $date_time, $date) = split 
(/\|/, $list);

#Compare form input to $userid
if ($input{'id_num'} eq $userid && $input{'id_num'} ne &quot;&quot;) {
$test = 1;
&notify;
&print_html;

}
}

if ($test == 0) {
&invalid_id;
}
}

<--- 
More subs snipped out of here --->
#######################################################
#Notify Sender that card was picked up
sub notify {
open(MAIL, &quot;| /usr/sbin/sendmail -t&quot;) || die &quot;Error&quot;;
$r = select(MAIL); $|=1;
print &quot;To: $input{'senderemail'}\n&quot;;
print &quot;From: postman\@thefarthing.com\n&quot;;
print &quot;Subject: $input{'name'} has picked up their card!\n\n&quot;;
print &quot;$input{'name'} has picked up their card that you sent\n&quot;;
print &quot;from theFARthing.com!\n\n&quot;;
print &quot;Thank you for using our card service and we hope\n&quot;;
print &quot;that you return soon.\n\n&quot;;
print &quot;theFARthing.com Team\n&quot;;
close (MAIL);
select($r);
}
 
Hi,

Try sending the email BEFORE you set the content type and printing any html (&print_html;).

Just a thought,

Tim --
Tim <tim@planetedge.co.uk>
 
Unfortunately, I have tried that..... I have put it at the beginning of the sub, the end of the sub, moved it to the elsif statement that calls pickup_card, both before and after the &pickup_card, and I just can't seem to get it to send that email......

I am not getting any errors on the logs, I am not showing any traffic on the mail logs, it is like the sub is not there at all. Very strange.

How do I do an alert box in perl? Maybe I can add one to the sub to see if it is being called at all..... Maybe I will also try to move one of the other subs in that I know works and see what happens.....

Any other ideas?
 
What is &quot;¬ify&quot;? You sub is called &quot;notify&quot; but you appear to be calling &quot;¬ify&quot;. Meddle not in the affairs of dragons,
For you are crunchy, and good with mustard.
 
Not sure why you are seeing it that way.... Shows as &quot;&notify;&quot; on my side.... however, that character is & n o t ; (Spaced out so hopefully it will not be shown as a special char)

I did change the name to got_it, and still have the same issue....

This one is driving me completely nuts......
 
I am still seeing something wierd in your posts! The character I'm seeing in front of &quot;ify&quot; is the &quot;NOT&quot; character, which I guess is because it looks like the html character &amp;not to the html parser. It should be looking for a semicolon after &amp;not but appears not to. BTW, this is in IE 5.5. Meddle not in the affairs of dragons,
For you are crunchy, and good with mustard.
 
I don't usually use 'select', so I might be barking up the wrong tree in the wrong forrest, but, maybe try loosing the 'select' syntax and print explicitly to MAIL.

Code:
open(MAIL, &quot;| /usr/sbin/sendmail -t&quot;) || die &quot;Error&quot;;
print MAIL &quot;To: $input{'senderemail'}\n&quot;;
print MAIL &quot;From: postman\@thefarthing.com\n&quot;;
print MAIL &quot;Subject: $input{'name'} has picked up their card!\n\n&quot;;
print MAIL &quot;$input{'name'} has picked up their card that you sent\n&quot;;
print MAIL &quot;from theFARthing.com!\n\n&quot;;
print MAIL &quot;Thank you for using our card service and we hope\n&quot;;
print MAIL &quot;that you return soon.\n\n&quot;;
print MAIL &quot;theFARthing.com Team\n&quot;;
close (MAIL);

I don't have time at the moment to experiment with it, but, I though this might be worth trying.

HTH



keep the rudder amid ship and beware the odd typo
 
First of all, thank you to everyone that has offered help and suggestions, I really appreciate it....

tsdragon, I normally use Netscape 4.77, so everything showed the way it should here. Looks like you may have found an 'undocumented feature' in IE 5.5 since it is showing the 'NOT' symbol in these posts. Seems very strange that it would read & notify ; as & not ; to me.....

HTH, I tried your idea of eliminating the select, but it still didn't work.....

However, I did make some changes and it works now. Here is what I have now

Code:
sub got_it {
&pickup_card;
open(MAIL, &quot;| /usr/sbin/sendmail -t&quot;) || die &quot;Error&quot;;
$r = select(MAIL); $|=1;
print &quot;To: $senderemail\n&quot;;
print &quot;From: postman\@thefarthing.com\n&quot;;
print &quot;Subject: $name has picked up their card!\n\n&quot;;
print &quot;$name has picked up their card that you sent\n&quot;;
print &quot;from theFARthing.com!\n\n&quot;;
print &quot;Thank you for using our card service and we hope\n&quot;;
print &quot;that you return soon.\n\n&quot;;
print &quot;theFARthing.com Team\n&quot;;
close (MAIL);
select($r);
	print &PrintHeader;
	&print_html;
}

It was definitely a 'light bulb moment' when I changed the variable names. If you look back, I originally had the variables as $input{'var_name'} and I was looking the code back over and noticed that when I was reading the database, I was reading them into $var_name.

What I believe was happening was with the original format of $input{'var_name'} I was essentially trying to send an email with a value of null for the recipient's name, so the mail server wouldn't send the email.

To be honest, when I saw that, I really felt like a newbie. While I am pretty new to the PERL language, I have been programming for several years and I do not normally make those types of mistakes. I just had to say 'DOH!' when it worked...... :)

Once again, thanks to everyone that offered input for this problem.
Jim
 
Don't feel too bad about it. One of perl's nice features - not having to declare and initialize every variable you use - has probably bitten every perl programmer more than once, not matter what their experience level. Besides, the dumbest mistakes are always the hardest to find. Meddle not in the affairs of dragons,
For you are crunchy, and good with mustard.
 
'[tt]use strict (&quot;vars&quot;);[/tt]' to avoid that particular set of teeth. &quot;If you think you're too small to make a difference, try spending a night in a closed tent with a mosquito.&quot;
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top