The code below is from a simple PHP script that sends a test email. How can I get a clickable link inside this text based message string? Note: My Page is going to be the clickable link. $message = "Please Click on the link here: My Page";
<a href='mypage.html'>My Page</a> Code (markup): Not quite sure why this is a PHP question, should be more into a basic HTML question.
Sorry I didn't clarify.....When I run the php email script it sends me the code <a href='mypage.html'>My Page</a> Code (markup): and not the link. Regards, Panda123
$headers = "MIME-Version: 1.0" . "\r\n"; $headers .= "Content-type:text/html;charset=UTF-8" . "\r\n"; // More headers $headers .= 'From: <webmaster@example.com>' . "\r\n"; $headers .= 'Cc: myboss@example.com' . "\r\n"; mail($to,$subject,$message,$headers); Code (php): You forgot to set the MIME headers for the email
Hi Einheijar, thanks for the reply! I changed the headers to exactly what you had and I still get a text email with the code and not an html email with the link. Here is a generic version of the code I'm using without my info. Just generic info: <?php $msg=""; if(isset($_POST['submit'])) { $from_add = "support@XXXXXXXXXX.com"; $to_add = "support@XXXXXXXXXX.com"; $subject = "Test Subject"; $message = "Test Email Message - Click Here: <a href='https://www.google.com'>Test</a>"; $headers = "MIME-Version: 1.0" . "\r\n"; $headers .= "Content-type:text/html;charset=UTF-8" . "\r\n"; //$headers = 'MIME-Version: 1.0' . "\r\n"; //$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; $headers = "From: $from_add \r\n"; $headers .= "Reply-To: $from_add \r\n"; $headers .= "Return-Path: $from_add\r\n"; $headers .= "X-Mailer: PHP \r\n"; if(mail($to_add,$subject,$message,$headers)) { $msg = "Mail sent OK"; } else { $msg = "Error sending email!"; } } ?> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <title>Test form to email</title> </head> <body> <?php echo $msg ?> <p> <form action='<?php echo htmlentities($_SERVER['PHP_SELF']); ?>' method='post'> <input type='submit' name='submit' value='Submit'> </form> </p> </body> </html> Code (markup):
on line # 16 you are missing a dot that is overwriting the $headers. instead of $headers ="From: $from_add \r\n" use $headers.="From:$from_add \r\n"