Forum Moderators: open
I am building an HTML email for a client who will be sending to about 20,000 users. Within the email is a link to an external PHP login site that I have already built. I need to pass along the user's email when they navigate to the external PHP site. I'm thinking the link will look something like this:
http://myexternalsite.php?email=recipients_email_address
How do I obtain 'recipients_email_address'? I'm a little new to HTML emails and am not sure if I can use JavaScript?
Thanks for any help,
wandoledzep
[edited by: tedster at 7:58 pm (utc) on June 30, 2009]
[edit reason] de-linked the example address [/edit]
How do I obtain 'recipients_email_address'?
I am presuming in generating this email it will be reading through the recipient list to determine who to send to, giving you options to customize the email. Doesn't matter if it's database driven or plain text, you should have something like this:
open email
store email in $letter
while (database result) {
($email,$fname,$lname) = [your database query method]
$thisletter = $letter;
$thisletter = [substitute letter marker for $email]
$thisletter = [substitute letter marker for $fname]
$thisletter = [substitute letter marker for $lname]
}
or
while (reading text file) {
($email,$fname,$lname) = [your line parsing method]
$thisletter = $letter;
$thisletter = [substitute letter marker for $email]
$thisletter = [substitute letter marker for $fname]
$thisletter = [substitute letter marker for $lname]
}
So if $letter is
<p>Dear [fname],</p>
<p><a href="$site?email=[email]">Subscribe</a></p>
The marker "[email]" would get replaced by $email, etc.
Now that you know how, let me say this is really a bad idea. Someone could spoof it by just doing
script?email=competitors-email@example.com
and if you have any functions to add an email automatically, it could cause potential problems: they could add thousands of emails that are not opted in, and on receipt of your emails you could get spamcop'ed and subsequently blacklisted.
A better method might be to put a unique record ID in the email,
while (database result) {
($record_id,$email,$fname,$lname) = [your database query method]
$thisletter = $letter;
$thisletter = [substitute letter marker for $record_id]
....
}
....
<p><a href="$site?r=[rec_id]">Subscribe</a></p>
Then when the variable "r" comes in to your script, do a lookup to see if it has a matching record. If it doesn't, direct them to a signup form, they enter their email address and a confirmation email gets sent ot verify their opt-in.