How to send email include html code using php? -
this question has answer here:
how send email include html code using php ?
i tried use code.
<?php include("connect.php"); $email = "test_mail@hotmail.com"; $to = $email; $subject = "test subject"; $message = " <body style='margin: 0; padding: 0;'> <table border='1' cellpadding='0' cellspacing='0' width='100%'> <tr> <td> <img src='http://i.stack.imgur.com/jy9qum.jpg'/> </td> </tr> <tr> <td> test text </td> </tr> </table> </body> "; $headers = 'mime-version: 1.0' . "\r\n"; $headers .= 'content-type: text/html; charset=iso-8859-1' . "\r\n"; $headers .= 'from: example <noreply@example.com>' . "\r\n"; $headers .= 'return-path: return@example.com' . "\r\n"; mail($to, $subject, $message, $headers, '-freturn@example.com'); ?>
when open email it's show in email.
<body style='margin: 0; padding: 0;'> <table border='1' cellpadding='0' cellspacing='0' width='100%'> <tr> <td> <img src='http://i.stack.imgur.com/jy9qum.jpg'/> </td> </tr> <tr> <td> test text </td> </tr> </table> </body>
but want show this
how can ?
........................................................................................................................................................
reason being is, don't have <!doctype html>
, </html>
tags (and other tags) , html isn't being rendered proper/full html markup.
$message = " <!doctype html> <html> <head> <title></title> </head> <body style='margin: 0; padding: 0;'> <table border='1' cellpadding='0' cellspacing='0' width='100%'> <tr> <td> <img src='http://i.stack.imgur.com/jy9qum.jpg'/> </td> </tr> <tr> <td> test text </td> </tr> </table> </body> </html> ";
- which upon testing afterwards, successful.
foonotes: (edit)
even though placed answer, decided close question being exact duplicate of other question how send mail using php insert html mail content? nonrespondant , answer given in there, answered posted code.
Comments
Post a Comment