Viola Posted November 24, 2009 Share Posted November 24, 2009 Hi I'm having a bit of trouble including a link to my website in an email and was wondering if anyone can help? Just before I call the mail function, I put: echo "<pre>"; print_r($msg['body']); echo "</pre>"; so that I can see if the path is being passed into the mail function correctly. The link is passed into mail() as: <a href="http://mydomain.com/support/support_downloads.php">Click here to go to our downloads page</a> However, when I get the email (which for testing purposes I'm sending to myself), it says this: <a href="http://../support/support_downloads.php">Click here to go to our downloads page</a> Please can you can help me with trying to figure out what I'm doing wrong? Thanks in advance. Viola Quote Link to comment https://forums.phpfreaks.com/topic/182848-problem-including-href-link-in-mail-message/ Share on other sites More sharing options...
mikesta707 Posted November 24, 2009 Share Posted November 24, 2009 http://php.net/manual/en/function.mail.php you need to set the email type to text/html for html to work via the headers $headers = 'MIME-Version: 1.0' . "\r\n"; $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; Quote Link to comment https://forums.phpfreaks.com/topic/182848-problem-including-href-link-in-mail-message/#findComment-965106 Share on other sites More sharing options...
Viola Posted November 25, 2009 Author Share Posted November 25, 2009 Thanks mikesta707. Unfortunately, I'm already doing that. The rest of the html message displays fine. In case it sheds any more light -- I looked at the message source and that shows the link as <a href="../support/support_downloads.php">Click here to go to our downloads page</a> For some reason, mail() seems to be taking my url and converting it to a relative path. Not sure why or what I need to do to get it to accept my url as-is. Quote Link to comment https://forums.phpfreaks.com/topic/182848-problem-including-href-link-in-mail-message/#findComment-965162 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.