Jump to content


Photo

HTML in email


  • Please log in to reply
9 replies to this topic

#1 hector vox

hector vox
  • New Members
  • Pip
  • Newbie
  • 5 posts

Posted 20 September 2006 - 02:31 PM

Hello,

I'm having a lot of difficulty getting HTML into an email. The link won't function in the email: <p> To confirm,  <a>click this link </a> </p>  is what appears in the email. I think it must be to do with the " or ' around the $body bit. tried various things, but  I can't make it work. Help!

<?php 
	
	
	
 	$headers ="From:newsletter@northavenspeakers.com\r\n";
	$headers .="Reply-To:newsletter@northavenspeakers.com\r\n";
	$headers .="Content-Type: text/html;\r\n charset=\"iso-8859-1\"\r\n";
	
	if (isset( $_POST['submit'])) {
	$email = $_POST['email'];
	$body = '
	<html>
		<head> 
		<title> Subscription to Northaven Speakers Club </head>
		</head>
		
		<body>
		<P> You have subscribed to receive Northaven Speakers Club newsletter </P>
	 <P> To confirm,  <a "href=www.thethingis.co.uk/speakers/confirm?email=?'.$email.'">click this link </a> </P>
	</body>
	</html>';
	mail ($_POST['email'], "Subscribe to Northaven Speakers", $body, $headers);
	echo "trying to send something";
    unset ( $_POST['submit'] ) ;
	};
	
	?>


#2 hector vox

hector vox
  • New Members
  • Pip
  • Newbie
  • 5 posts

Posted 20 September 2006 - 04:18 PM

Is it possible that I have specified the wrong format in the $header variable. I've tried a lot of solutions to this problem, but what ever I do I get the same result as described above. Or, am I doing something really stupid? I've spent a while staring at this one.

#3 onlyican

onlyican
  • Members
  • PipPipPip
  • Advanced Member
  • 921 posts
  • LocationHants - UK

Posted 20 September 2006 - 04:19 PM

This is my Mailer example

<?php
$to = $email;
$subject = "Registration with XX";

$message = "Hello ".$name."<br />\n"
."Thank you for registering with <a href='http://www.example.com'>Exmaple</a><br />\n"
."Your username is <strong>".$username."</stroing><br /><br />\n"

."If anyone sends you a message, an email will be sent to you letting you know, you can log in, and view your new messages<br />\n"


."If you have any problems, you can contact me on this email address (<a href='mailto:info@example.com'>info@example.com</a>)<br /><br />\n\n"

."Best Regards<br /><br />\n\n"

."Jamie<br />\n";

$headers  = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$headers .= 'To: '.$name.' <'.$email.'>,' . "\r\n";
$headers .= 'From: ME<info@example.com>' . "\r\n";

if(mail($to, $subject, $message, $headers)){
?>

Try that

and please please please check the email before sending the email
or you will open yourself up to a world of spam, (people using your form to spam other people)
Tell me the problem, I will try tell you the solution

#4 hector vox

hector vox
  • New Members
  • Pip
  • Newbie
  • 5 posts

Posted 20 September 2006 - 05:12 PM

I'll give that a go. What do you mean by check the email? Is it something to do with that little if at the end.

#5 onlyican

onlyican
  • Members
  • PipPipPip
  • Advanced Member
  • 921 posts
  • LocationHants - UK

Posted 20 September 2006 - 05:16 PM

no
I mean the fact you are using the email direct from the form, without validating it
People can put some code in there, and send 100's of emails from ur account, which in return will black list you
Tell me the problem, I will try tell you the solution

#6 craygo

craygo
  • Staff Alumni
  • Advanced Member
  • 1,973 posts
  • LocationRhode Island

Posted 20 September 2006 - 05:23 PM

This line is wrong

<a "href=www.thethingis.co.uk/speakers/confirm?email=?'.$email.'">

should be

<a href="www.thethingis.co.uk/speakers/confirm?email=?'.$email.'">

Ray

#7 hector vox

hector vox
  • New Members
  • Pip
  • Newbie
  • 5 posts

Posted 20 September 2006 - 05:45 PM

Thanks Ray, that's exactly what I needed. This validation thing, am I ok if I limit the lenght of the email? Thankks again,

hector.

#8 craygo

craygo
  • Staff Alumni
  • Advanced Member
  • 1,973 posts
  • LocationRhode Island

Posted 20 September 2006 - 05:56 PM

It's not the limit. You should have your script check your variables and make sure they are valid. What they are saying is someone could use your page to start sending out emails from your server by just adding things to your url. There is a script out there which will validate and email address as best as possible. I will post when I find it.

You should not make a page like this public!!! What are you using it for anyway??

Ray

#9 hector vox

hector vox
  • New Members
  • Pip
  • Newbie
  • 5 posts

Posted 20 September 2006 - 06:24 PM

The idea is that you click the link, and confirm that you want to aign up to a mailing list. I can tell that you're going to tell me that the whole method I'm using is wrong.

So you click url/confirm?email=you@email.com, which Gets the email adress, signs you up and sends you another email with a little present for signing up. Thats my plan, but as you've probably guessed, I'm not exactly sure what I'm doing. Cheers for your time,

Jimmy

#10 onlyican

onlyican
  • Members
  • PipPipPip
  • Advanced Member
  • 921 posts
  • LocationHants - UK

Posted 20 September 2006 - 06:53 PM

what I do is
Add an extra field in the Database
Create a UNIQUE id and add it in there
Unique ID can be something like
$unique_id = md5($email);
(Encrypts the email to a 32 bit code)

or maybe using RAND functions,
Also combined with md5

I am not going to give my code, as I dont want people starting to hack my sites. but I create a Unique ID, and then md5 encrypt it
Tell me the problem, I will try tell you the solution




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users