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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Can a web page send an email on being loaded?

Status
Not open for further replies.

engcomp

Programmer
Jun 18, 1999
66
0
0
AU
Don't ask why I should want this. If your page gets hundreds or thousands of hits per day, you wouldn't want it. But my pages get one hit every few days. I would like the page to send me an enmail when it gets hit.

1. Can this be done?

2. If so, how, and what information can it send?

Thank you for a fine forum, Helmut
 
hi
1. yes
2.here:
..
function mailme(){
var subj=escape("i'm hit!")
var bd=escape("yea, i'm hit today!!")
var str="mailto:my@address.com?subject="+subj+"&body="+bd
top.location.href=str
}
..
<body onload=&quot;mailme()&quot;>
..
you of course are able to pass address or subj or anything as a parameter to that function

and there is a good faq on this in html forum.. (by Mike as i remember)
:)
 
Thank you very much, tuz

My apology for the delay in replying, but I was away.

The solution you suggest fires up the user's email client software. What I need is for the email to be sent automatically when the page loads, without the user even knowing that an email has been sent. The information for the email comes from a cookie and REMOTE_ADDR.

Something like FormMail.pl, but with onload=... instead of form action=...

So the question is still - can this be done?

Thank you, Helmut
 
well, then may be open a popup onload & submit a form on it's *load* & then close this popup? (freaky, i know)

??? Victor
 
If you know a little perl, you can write your own script to do what you want. Use the script as the source of an image tag in your web page, and after the script sends you the email it should return an &quot;Content-type: image/gif\n\n&quot; header and a 1x1 pixel transparent gif image. You can hide the image tag almost anywhere on the page and it won't be noticeable. I've got a perl subroutine of only a few lines that will send the header and the image, without having to read an image file. Let me know if you want it. Tracy Dryden
tracy@bydisn.com

Meddle not in the affairs of dragons,
For you are crunchy, and good with mustard.
 
Exactly what I hoped to learn. Thank you both very much.

Special thanks to Tracy for the offer to send the script.

Helmut
engcomp@ozemail.com.au
 
Tracy, i'd like to see how to hardcode an image too, if you wouldn't mind.. :)

(or may be just some source on it..)

thanks

Code:
vituzz@rambler.ru
Victor
 
Hi, Victor

Here is what Tracy sent me:

sub PrintPixel
{

my(@bytes) = (71,73,70,56,57,97,1,0,1,0,128,0,0,255,255,255,0,0,0,33,249,4,5,20,0,0,0,44,0,0,0,0,1,0,1,0,0,2,2,68,1,0,59);
print &quot;Content-type: image/gif\n\n&quot;;
print pack('C*', @bytes);
return 1;

}

I assume the @bytes array stands for:
GIF89a1010Ç00___000!•45¶0000,000010100022D10;

Generous Tracy will probably email the same to you.

Regards, Helmut
 
wooo.. i need some comments on that :))))) source or something.. my brains feel the new stuff, i'm just addicted, i won't feel good unless i would knowout how EXACTLY does it work..

ok, i'm gone seeking in the NET on this subj :)))) Victor
 
You will share it with us when you get to the bottom of it?
 
Actually, it's really simple. All I did was create a 1x1 pixel transparent gif image in a graphics program, then open it with a hex editor and copy the decimal values of the bytes it contained. That's what the array @bytes contains. The subroutine just prints the appropriate content-type header for a gif image, then packs all the decimal values for the bytes into a character string and prints it. Then it returns TRUE. The &quot;pack&quot; command can be complicated to figure out how to use, but it has it uses.

You can cut-n-paste the subroutine from above, or I can email it to you.
Tracy Dryden
tracy@bydisn.com

Meddle not in the affairs of dragons,
For you are crunchy, and good with mustard.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top