开发者

cannot send mail in html format

开发者 https://www.devze.com 2023-02-13 19:27 出处:网络
I am working on a site, that uses mail() function of php to send emails. However the emails are not delivered properly as the server has got some problems sending html emails. Please help... Code is a

I am working on a site, that uses mail() function of php to send emails. However the emails are not delivered properly as the server has got some problems sending html emails. Please help... Code is as follows:

<?php
$fromAddr = 'Frendzpark <admin@Frendzpark.co.cc>'; // the address to show in From field.
$recipientAddr = 'rautsanket2105@gmail.com';
$subjectStr = 'Demo:Account created successfully';

$mailBodyText = <<<HHHHHHHHHHHHHH
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8">
<title>Account created successfully</title>
</head>
<body>
<p>
<div style="color: #ff4e0a; height: 100px; font-weight: bold; font-size: 70px; font-family: 'Maiandra GD'; text-align: left; padding-left: 10px;">
        Chatmasti</div><hr />
    <div style="font-family: 'Trebuchet MS'; height: 160px; padding-left: 30px; font-size: 12px; border-left-width: thin; border-left-color: #ccccff; border-bottom-width: thin; border-bottom-color: #ccccff; border-right-width: thin; border-right-color: #ccccff;">
        Thank you for signing up. Your account has been created successfully and your account
        details are as follows:<br />
        <br />
        Username: <b>user</b><br />
        Password: <b>pass</b><br />
            <br />
        You can start chatting after verifying your email address. To verify the email address
        please click the link below:<br />
        <a href="http://www.chatmasti.uk.tc/verify=3973hfuhfri23892">http://www.chatmasti.uk.tc/verify=3973hfuhfri23892</a><br />
        Hope you enjoy this free service.<br />
        <br />
        Regards,<br />
        Sanket Raut.<br />
        Webmaster,<br />
        Chatmasti</div>
</p>
</body>
</html>
HHHHHHHHHHHHHH;

$headers= <<<TTTTTTTTTTTT
From: $fromAddr
MIME-Version: 1.0
Content-Type: text/html;
TTTT开发者_开发知识库TTTTTTTT;

$sent=mail( $recipientAddr , $subjectStr , $mailBodyText, $headers);
if($sent)
 print "Mail sent";
else
 print "Error";

?>


I think you need to specify the charset. Add the charset option behind the Content-Type option, like this:

Content-type: text/html; charset=iso-8859-1


Maybe it will be better idea to use Swift mailing solutionand do not reinvent the wheel?

http://swiftmailer.org/

0

精彩评论

暂无评论...
验证码 换一张
取 消