Blunketts dog Posted February 28, 2009 Share Posted February 28, 2009 Hi there, when i run this code: <?php $message = ' <html> <body> <p>Click <a href = "www.yahoo.com">here </a>for yahoo</p> </body> </html>'; $headers = 'MIME-Version: 1.0' . "\r\n"; $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; $headers .= 'From: Me <Me@home.com>'; mail ('user@home.com', 'Test mail', $message, $headers); ?> I am hoping to get an email that contains a link that I can click on to get to yahoo. What actually happens is i just get an email that says 'Click here to go to yahoo' but no clickable link. Can anyone tell me what i am doing wrong? Many thanks Quote Link to comment Share on other sites More sharing options...
only one Posted February 28, 2009 Share Posted February 28, 2009 It's probobally nothing to do with your code, but your email software is blocking the link incase it's spam. Quote Link to comment Share on other sites More sharing options...
Blunketts dog Posted February 28, 2009 Author Share Posted February 28, 2009 It's probobally nothing to do with your code, but your email software is blocking the link incase it's spam. Oh. Is there a way round this then. I have looked through my emails, and i have recieved some that contain links that work fine. How do they manage it? Quote Link to comment Share on other sites More sharing options...
shadiadiph Posted February 28, 2009 Share Posted February 28, 2009 try using 'http://www.yahoo.com' not "www.yahoo.com" my server doesn't like it with "" only with '' in emails Quote Link to comment Share on other sites More sharing options...
shadiadiph Posted February 28, 2009 Share Posted February 28, 2009 if what i suggested fails try changing your headers to $headers .= "MIME-Version: 1.0\n"; $headers .= "Content-type: text/html; charset=iso-8859-1"; hope i have helped but on my server if i put "www.yahoo.com" it wouldn't work either has to be 'http://www.yahoo.com' for it to work on mine Quote Link to comment Share on other sites More sharing options...
cooldude832 Posted February 28, 2009 Share Posted February 28, 2009 is your mamilbox blocking the link cause you aren't using enough headers to ID your email address you are sending from? If it can phrase the html odds are that is the answer Quote Link to comment Share on other sites More sharing options...
Blunketts dog Posted February 28, 2009 Author Share Posted February 28, 2009 I treid this: try using 'http://www.yahoo.com' not "www.yahoo.com" my server doesn't like it with "" only with '' in emails and it worked fine. Many thanks I will bear this if what i suggested fails try changing your headers to $headers .= "MIME-Version: 1.0\n"; $headers .= "Content-type: text/html; charset=iso-8859-1"; hope i have helped but on my server if i put "www.yahoo.com" it wouldn't work either has to be 'http://www.yahoo.com' for it to work on mine and this is your mamilbox blocking the link cause you aren't using enough headers to ID your email address you are sending from? If it can phrase the html odds are that is the answer in mind if I run into any problems. Thanks for all your help - this is my first go at a php project and i thought i had fallen at the final hurdle! Quote Link to comment Share on other sites More sharing options...
shadiadiph Posted February 28, 2009 Share Posted February 28, 2009 ok no problem you are welcome please mark this topic as solved Quote Link to comment Share on other sites More sharing options...
Blunketts dog Posted February 28, 2009 Author Share Posted February 28, 2009 OK, I got that working but what i really want to do is use an address I have in a variable as so: <?php $link = "http://www.yahoo.co.uk" $message = ' <html> <body> <p>Click <a href = $link>here </a>for yahoo</p> </body> </html>'; $headers = 'MIME-Version: 1.0' . "\r\n"; $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; $headers .= 'From: Me <Me@home.com>'; mail ('user@home.com', 'Test mail', $message, $headers); ?> but this gives me an email that says 'click for yahoo' with no clickable bit and no sign of either the address or the variable it has come from. Is there a way round this or have i overlooked something more obvious? Thanks again Quote Link to comment Share on other sites More sharing options...
shadiadiph Posted February 28, 2009 Share Posted February 28, 2009 try this $link = "http://www.yahoo.co.uk"; $message = ' <html> <body> <p>Click <a href ='$link'>here </a>for yahoo</p> </body> </html>'; Quote Link to comment Share on other sites More sharing options...
Blunketts dog Posted February 28, 2009 Author Share Posted February 28, 2009 try this $link = "http://www.yahoo.co.uk"; $message = ' <html> <body> <p>Click <a href ='$link'>here </a>for yahoo</p> </body> </html>'; that returns: Parse error: syntax error, unexpected T_VARIABLE Quote Link to comment Share on other sites More sharing options...
DarkSuperHero Posted February 28, 2009 Share Posted February 28, 2009 You guys forgot to escape the ' inside <?php $link = "http://www.yahoo.co.uk"; $message = ' <html> <body> <p>Click <a href =\'$link\'>here </a>for yahoo</p> </body> </html>'; Quote Link to comment Share on other sites More sharing options...
cooldude832 Posted February 28, 2009 Share Posted February 28, 2009 http://www.php.net/manual/en/language.types.string.php#language.types.string.syntax.double You need to read about what type of quotes to use where Quote Link to comment Share on other sites More sharing options...
Blunketts dog Posted February 28, 2009 Author Share Posted February 28, 2009 You guys forgot to escape the ' inside <?php $link = "http://www.yahoo.co.uk"; $message = ' <html> <body> <p>Click <a href =\'$link\'>here </a>for yahoo</p> </body> </html>'; That just gives an email of 'click here for yahoo' with no hyperlink http://www.php.net/manual/en/language.types.string.php#language.types.string.syntax.double You need to read about what type of quotes to use where I had a look at it this but it didn't really help me. Its all a bit too complex for me to get my head round what I am doing and where i am going wrong Quote Link to comment Share on other sites More sharing options...
Blunketts dog Posted March 1, 2009 Author Share Posted March 1, 2009 i got it working by doing this: <?php $link = ' "http://www.yahoo.co.uk" '; $message = ' <html> <body> <p>Click <a href ='.$link.'>here </a>for yahoo</p> </body> </html>'; Quote Link to comment Share on other sites More sharing options...
haku Posted March 1, 2009 Share Posted March 1, 2009 Make sure you check that in outlook, thunderbird, hotmail, gmail and a cell phone or two - html emails are notoriously buggy. Each mail client renders them differently. I avoid them altogether - not worth the hassles. Quote Link to comment Share on other sites More sharing options...
shadiadiph Posted March 1, 2009 Share Posted March 1, 2009 oops sorry i forgot you needed the extra '' on the link definition Quote Link to comment 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.