11Tami Posted August 12, 2007 Share Posted August 12, 2007 Hello, I know how to send something to an email. How can I add a link to the email so that if someone clicks on the link some php will execute? What php I want to execute is that when they click on the link the letter "v" is sent to a database. I know how to send something to a database, I just don't know how to tie all this together with the an address link in their email. All I'm trying to do is send something to someones email and when they click on the link it will prove there email is real and not a bogus email address. I'm just missing this one piece on -----how to make the web site address link in their email activate some php. Please let me know, thanks a lot. Quote Link to comment https://forums.phpfreaks.com/topic/64477-adding-php-to-the-message-of-an-email/ Share on other sites More sharing options...
cooldude832 Posted August 12, 2007 Share Posted August 12, 2007 make the email html not text (have to mod headers) then apply the link in it to a page on your site that will process with some hashed key to query off the db. Quote Link to comment https://forums.phpfreaks.com/topic/64477-adding-php-to-the-message-of-an-email/#findComment-321438 Share on other sites More sharing options...
11Tami Posted August 12, 2007 Author Share Posted August 12, 2007 I'm sure I'll need to come back to this post, I'll probably get stuck soon. But, that takes the fuzziness off, I'll get started and see what happens. Thanks that helped a lot! Quote Link to comment https://forums.phpfreaks.com/topic/64477-adding-php-to-the-message-of-an-email/#findComment-321442 Share on other sites More sharing options...
ballhogjoni Posted August 12, 2007 Share Posted August 12, 2007 the link you send in an email should contain http://example.com?letter=v then when the person clicks the link and taken to http://example.com?letter=v you will want to set up your code on page http://example.com to accept the value of letter, which in this case would be v. The way to do that is to use $_GET['letter'] and then setup your datbase query to something like "INSERT INTO tablename (letter) VALUES '$_GET['letter']'"; Quote Link to comment https://forums.phpfreaks.com/topic/64477-adding-php-to-the-message-of-an-email/#findComment-321449 Share on other sites More sharing options...
11Tami Posted August 12, 2007 Author Share Posted August 12, 2007 Thank you, I appreciate that very much. The emails aren't accepting regular html. It doesn't let me put a closing tag on the A link in this forum but my following A link is correct. $messageproper = "<a href='validationpage.php'>why arent emails accepting this html?<closingslash a>" Please let me know, thanks. Quote Link to comment https://forums.phpfreaks.com/topic/64477-adding-php-to-the-message-of-an-email/#findComment-321463 Share on other sites More sharing options...
11Tami Posted August 12, 2007 Author Share Posted August 12, 2007 Heres the link I'm using for html in emails. http://www.w3schools.com/php/func_mail_mail.asp Here's what I'm using in the php and the email is sending, but it shows this just as is in the email. Its not reading any of this as html. Anyone see whats wrong with my html email code? Thanks. $validateemail = 'anemail@address.com ; $from = 'noreplysupportaddress'; $subject = "Email validation" ; $messageproper = "<html> <head> <title>HTML email</title> </head> <body> <div><span style='font-family:arial,sans-serif;font-size:14px'>Testing text and html in an email.<a href='http:www.example.com/validate.php?username=$username ' target='blank'>Validate Your Email</a></span></div> </body> </html>"; $headers = "MIME-Version: 1.0" . "\r\n"; $headers .= "Content-type:text/html;charset=iso-8859-1" . "\r\n"; $headers = "From: <$from>\r\n"; $headers .= "Reply-To: ".preg_replace('/[\r\n]+/', ' ', $from)."\r\n"; mail($validateemail, $subject, $messageproper, $headers); Quote Link to comment https://forums.phpfreaks.com/topic/64477-adding-php-to-the-message-of-an-email/#findComment-321484 Share on other sites More sharing options...
cooldude832 Posted August 12, 2007 Share Posted August 12, 2007 really you want to include 2 vars in the link the username and a random passkey that mysql will check to see if it matches at that username Quote Link to comment https://forums.phpfreaks.com/topic/64477-adding-php-to-the-message-of-an-email/#findComment-321718 Share on other sites More sharing options...
11Tami Posted August 12, 2007 Author Share Posted August 12, 2007 Anyone know anything about putting html in email and why my just above email code isn't working? Thanks. Quote Link to comment https://forums.phpfreaks.com/topic/64477-adding-php-to-the-message-of-an-email/#findComment-321823 Share on other sites More sharing options...
11Tami Posted August 12, 2007 Author Share Posted August 12, 2007 I got the validation part working, just need help with why the emails aren't reading my A links and html. Quote Link to comment https://forums.phpfreaks.com/topic/64477-adding-php-to-the-message-of-an-email/#findComment-321850 Share on other sites More sharing options...
ballhogjoni Posted August 12, 2007 Share Posted August 12, 2007 <span style='font-family:arial,sans-serif;font-size:14px'>Testing text and html in an email.<a href='http:www.example.com/validate.php?username=$username ' target='blank'> try <span style=\"font-family:arial,sans-serif;font-size:14px\">Testing text and html in an email.<a href=\"http:www.example.com/validate.php?username=$username \" target=\"blank\"> Quote Link to comment https://forums.phpfreaks.com/topic/64477-adding-php-to-the-message-of-an-email/#findComment-321916 Share on other sites More sharing options...
11Tami Posted August 13, 2007 Author Share Posted August 13, 2007 I appreciate that, thats not it. Its showing all this as is even your added escape slashes. <head> <title>HTML email</title> </head> <body> Quote Link to comment https://forums.phpfreaks.com/topic/64477-adding-php-to-the-message-of-an-email/#findComment-322038 Share on other sites More sharing options...
ballhogjoni Posted August 13, 2007 Share Posted August 13, 2007 what email provider are you sending these email to? Quote Link to comment https://forums.phpfreaks.com/topic/64477-adding-php-to-the-message-of-an-email/#findComment-322040 Share on other sites More sharing options...
11Tami Posted August 13, 2007 Author Share Posted August 13, 2007 Msn Quote Link to comment https://forums.phpfreaks.com/topic/64477-adding-php-to-the-message-of-an-email/#findComment-322041 Share on other sites More sharing options...
ballhogjoni Posted August 13, 2007 Share Posted August 13, 2007 try taking all the <html><head> and <body> stuff. Just leave the message and link intact. Quote Link to comment https://forums.phpfreaks.com/topic/64477-adding-php-to-the-message-of-an-email/#findComment-322045 Share on other sites More sharing options...
11Tami Posted August 13, 2007 Author Share Posted August 13, 2007 Strange, didn't help, I also sent it to two other emails, aol and a no name brand. Same thing, doesn't read the html. or the A link even all by itself with the escape slashes. I've been reading all over google, its working for everyone else, why not for me? Quote Link to comment https://forums.phpfreaks.com/topic/64477-adding-php-to-the-message-of-an-email/#findComment-322058 Share on other sites More sharing options...
ballhogjoni Posted August 13, 2007 Share Posted August 13, 2007 heres the code I use and it works evertime. $headers = 'From: me@mydomain.com' . "\r\n" . 'Reply-To: me@mydomain.com' . "\r\n" . 'X-Mailer: PHP/' . phpversion(); $subject = "Subject Line"; $message = "Dear SonSo, this is your activation link to join our website. In order to confirm your membership please click on the following link: http://www.xxxx.com/xxxx/confirm.php?ID=1 Thank you for joining"; mail(theiremail@theirdomain.com, $subject, $message, $headers) Sometimes I add a a random key to the link so that it is a more secure confirmation. Quote Link to comment https://forums.phpfreaks.com/topic/64477-adding-php-to-the-message-of-an-email/#findComment-322088 Share on other sites More sharing options...
11Tami Posted August 13, 2007 Author Share Posted August 13, 2007 Thanks, how are they able to click on your link, I don't see a link. I need to know how to do html in an email for other reasons as well. So I can format some emails I send. Here's all of it. Its only reading html like this <span> etc. How to get an email to read html? Thanks very much. <?php ?> <form action="<?php $_SERVER['PHP_SELF'] ;?>" method='post'> <input type='text' name='username' size=15> <span>User name</span><br /> <input name='email' size=15> <span>Email</span><br /> <input type='submit' name="submit" value='Submit'><br /><br /> </form> <?php if (isset($_POST['submit'])) { $username = $_POST['username'] ; $pemail = $_POST['email'] ; $from = 'noreplysupport@somesite.com'; $subject = "Validation Email" ; $messageproper = "<span style=\"font-family:arial,sans-serif;font-size:14px\">Just click on the following link to validate your email.</span> <a href=\"http://www.example.com/validate.php?username=$username\" target=\"blank\">Validate</a>"; $headers = "MIME-Version: 1.0" . "\r\n"; $headers .= "Content-type:text/html;charset=iso-8859-1" . "\r\n"; $headers = "From: <$from>\r\n"; $headers .= "Reply-To: ".preg_replace('/[\r\n]+/', ' ', $from)."\r\n"; mail($pemail, $subject, $messageproper, $headers); } ?> This doesn't work either: $messageproper = "<html><body><div><span style='font-family:arial,sans-serif;font-size:14px'>Just click on the following link to validate your email.</span><a href='http://www.example.com/validate.php?username=$username' target='blank'>Validate</a></div></body></html>"; Quote Link to comment https://forums.phpfreaks.com/topic/64477-adding-php-to-the-message-of-an-email/#findComment-322150 Share on other sites More sharing options...
ballhogjoni Posted August 13, 2007 Share Posted August 13, 2007 in most email accounts the http://whatever.com will become a link. No need to have the html. Quote Link to comment https://forums.phpfreaks.com/topic/64477-adding-php-to-the-message-of-an-email/#findComment-322324 Share on other sites More sharing options...
11Tami Posted August 13, 2007 Author Share Posted August 13, 2007 Thanks for all your great help~! ballhogjoni Turned out I was missing the tiny dots here!!! $headers . after the header variables. Works great now. Thanks again for being so nice and helpful! Tami Quote Link to comment https://forums.phpfreaks.com/topic/64477-adding-php-to-the-message-of-an-email/#findComment-322888 Share on other sites More sharing options...
Asperon Posted August 13, 2007 Share Posted August 13, 2007 $validateemail = 'anemail@address.com ; $from = 'noreplysupportaddress'; did you fix that missing ' in the first line? Quote Link to comment https://forums.phpfreaks.com/topic/64477-adding-php-to-the-message-of-an-email/#findComment-322894 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.