1

So I am sending an HTML e-mail which is an invitation, and I would want users to click Join! if they would want to join the invitation, but then I have no idea how to retrieve their e-mail addresses. I can only get hits of how many "Yes"es I have got, I can't see which e-mail has actually said yes. How can I get their e-mail address too? beside providing them with a text field asking them to fill it up.

Any thoughts? thanks :)

My cade so far:

<html>
<body>
    <form action="myserver.com" method="POST" target="_blank">
        <input type="hidden" name="answer" value="yes"/>
        <input type="submit" name="submit" value="Join!"/>
    </form>
</body>
</html>

For the server side, I am using PHP to retrieve the data. Could anything be done from there? I can't use PHP or JS in my e-mails as far as I know.

x29a
  • 1,761
  • 1
  • 24
  • 43
user3304841
  • 19
  • 1
  • 5
  • Which language are you using to retrieve the data? How does your server side (or JavaScript) code look like? – damian Feb 13 '14 at 07:49
  • 1
    you need to add some identification programatically, e.g. add another hidden field with the email address you are using for the current email. You cant copy/paste one HTML mail to everybody though. do you have access to programming languages and a server? – x29a Feb 13 '14 at 07:51
  • For the server side, I am using PHP to retrieve the data. Could anything be done from there? I can't use PHP in my e-mails as far as I know. But in the server side, I am using it. And I can be using any other language required, as long as it gets the job done. any help? :) – user3304841 Feb 13 '14 at 07:59
  • @x29a As for the email, only HTML. But then once the form is posted, I have access to all kinds of languages to retrieve the data. And the input hidden thing that you suggested, smart! But then I have 450 people who I want to send this e-mail too, so yup :( – user3304841 Feb 13 '14 at 08:16

2 Answers2

1

Since you mention PHP, why not send the email programmatically?

Assuming you have a working SMTP configuration (see Local SMTP), all email adresses in an array, you could use PHP to send out the emails.

See the examples at the resources for specific headers needed for HTML

<?php
$email_addresses = array('foo@bar.tld', 'no@name.it');

// subject
$subject = 'Invitation';

// message
$message = '
<html>
<body>
    <form action="myserver.com" method="POST" target="_blank">
        <input type="hidden" name="answer" value="yes"/>
        <input type="hidden" name="email" value="%placeholder%" />
        <input type="submit" name="submit" value="Join!"/>
    </form>
</body>
</html>
';

// To send HTML mail, the Content-type header must be set - general part of the header
$headers  = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$headers .= 'From: Invitation <your_email@example.com>' . "\r\n";

// iterate over all email addresses
foreach ($email_addresses as $address) 
{
    // specific version of header
    $header = $headers . 'To: ' . $address . ' . "\r\n";

    // specific version of message
    $msg = str_replace('%placeholder%', $address, $message);

    // Mail it
    mail($address, $subject, $msg, $header);
}
?>

As always, there are many ways to rome, so you could also input a link into the mail which has the email address (or some other sort of ID) as GET parameter.

Take special care with encodings (ISO vs UTF).

Also, your webserver will be the sender of the Email, so it might get caught in spamfilters if the address differs from the FROM field.

Getting PHP's mail() function to work can be a bit tricky, but the internet is full of solutions, so good luck!

Community
  • 1
  • 1
x29a
  • 1,761
  • 1
  • 24
  • 43
1

You would have to put their address in the href url as a parameter. It is the only way to get it back.

I won't bother putting all the PHP mail code in here but when you pass something like this:

$address = "their.email@gmail.com";
$msg = '... <a href="http://yoursite.com?email='.$address.'">click here</a> ...'
mail($address, $subject, $msg, $header);

It will render in the email like this:

<a href="http://yoursite.com?email=their.email@gmail.com">click here</a>

When they click it, it will send the parameter to your webpage, where you can access it with $_GET['email']

John
  • 11,985
  • 3
  • 45
  • 60