使用mail.php的HTML电子邮件

时间:2010-06-02 10:07:18

标签: html email-integration

您好我正在创建一个可以在我们的devbox上运行的电子邮件系统,但在我们的1& 1服务器上我收到内部服务器错误500.我生成电子邮件的方式是使用simple_dom_parser读取html文件并替换为指定的值。我已经设法收到现在发送的电子邮件,一切都在其中。这是代码

<html xmlns='http://www.w3.org/1999/xhtml'>
<head>
<meta http-equiv='Content-Type' content='text/html; charset=utf-8' />
<title>Untitled Document</title>
</head>
<body style='margin: 0; padding: 0; background-color: #eaeaea;'>
            <table width='500px' border='0' cellpadding='0' cellspacing='0' style='background-color: #fff; width:500px;' >
                <tr>
                    <td><img src='http://www.completelettingsolutions.co.uk/images/email/email_header.jpg' border='0' /></td>

                </tr>
            </table>
            <table width='450px' border='0' cellpadding='0' cellspacing='0' style='background-color: #fff; width:500px;' >
                <tr>
                    <td bgcolor='#FFFFFF' style='padding:0 16px;'  cellpadding='0' cellspacing='0' align="left">
                    <font>
                    <span id='fName' style='text-decoration: none;'></span> 
                        <br><br>
                        We've recieved a request for your password to be reset on Complete Letting Solutions. If you've not requested this then rest assured your details are safe and ignore this email!
                        <br><br>
                        Your Username: <span id='uName' style='text-decoration: none;'></span>
                        <br><br>
                        Your Password:  <span id='returnLink' style='text-decoration: none;'></span>               
                        <br><br>
                        Please note - the password reset link above will expire in 24 hours.
                        <br><br>
                        <font color="#4E69B2" size="2" >
                        <b>
                        Kind Regards,<br>
                        Complete Letting Solutions
                        </b>
                    </font>
                    </font>
                    </td>
                </tr>
            </table>
            <table width='500px' border='0' cellpadding='0' cellspacing='0' style='width:500px;'>
                <tr>
                    <td><img src='http://www.completelettingsolutions.co.uk/images/email/email_foot.jpg' border='0' /></td>
                </tr>
                </table>  
    </body>
    </html>

现在我需要做的就是将表对齐以使其居中。 Origionaly我把它们放在另一个表中并对齐td但是这给了我一个服务器错误。有没有人曾经经历过这个,有没有人知道如何解决它?两者的php版本都是5.3.2。

下面是

的代码

<html xmlns='http://www.w3.org/1999/xhtml'>
<head>
<meta http-equiv='Content-Type' content='text/html; charset=utf-8' />
<title>Untitled Document</title>
</head>
<body style='margin: 0; padding: 0; background-color: #eaeaea;'>
           <table width='100%' border='0' cellpadding='0' cellspacing='0' style='background-color: #eaeaea; width:100%;' >
    <tr>
        <td align='center'>
            <table width='500px' border='0' cellpadding='0' cellspacing='0' style='background-color: #fff; width:500px;' >
                <tr>
                    <td><img src='http://www.completelettingsolutions.co.uk/images/email/email_header.jpg' border='0' /></td>

                </tr>
            </table>
            <table width='450px' border='0' cellpadding='0' cellspacing='0' style='background-color: #fff; width:500px;' >
                <tr>
                    <td bgcolor='#FFFFFF' style='padding:0 16px;'  cellpadding='0' cellspacing='0' align="left">
                    <font>
                    <span id='fName' style='text-decoration: none;'></span> 
                        <br><br>
                        We've recieved a request for your password to be reset on Complete Letting Solutions. If you've not requested this then rest assured your details are safe and ignore this email!
                        <br><br>
                        Your Username: <span id='uName' style='text-decoration: none;'></span>
                        <br><br>
                        Your Password:  <span id='returnLink' style='text-decoration: none;'></span>               
                        <br><br>
                        Please note - the password reset link above will expire in 24 hours.
                        <br><br>
                        <font color="#4E69B2" size="2" >
                        <b>
                        Kind Regards,<br>
                        Complete Letting Solutions
                        </b>
                    </font>
                    </font>
                    </td>
                </tr>
            </table>
            <table width='500px' border='0' cellpadding='0' cellspacing='0' style='width:500px;'>
                <tr>
                    <td><img src='http://www.completelettingsolutions.co.uk/images/email/email_foot.jpg' border='0' /></td>
                </tr>
            </table>
                        </td>
    </tr>
</table>  
</body>
</html>
thank you.

1 个答案:

答案 0 :(得分:0)

工作示例:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html>

    <head>
        <meta http-equiv='Content-Type' content='text/html; charset=utf-8' />
        <title>Untitled Document</title>
    </head>

    <body style='margin:0; padding:0; background-color:#eaeaea;'>
        <table width='100%' border='0' cellpadding='0' cellspacing='0' style='background-color:#eaeaea; width:100%;' >
            <tr>
                <td align='center'>
                    <table width='500px' border='0' cellpadding='0' cellspacing='0' style='background-color: #fff; width:500px;' >
                        <tr>
                            <td>
                                <img src='http://www.completelettingsolutions.co.uk/images/email/email_header.jpg' border='0' />
                            </td>
                        </tr>
                    </table>
                    <table width='450px' border='0' cellpadding='0' cellspacing='0' style='background-color: #fff; width:500px;' >
                        <tr>
                            <td bgcolor='#FFFFFF' style='padding:0 16px;'  cellpadding='0' cellspacing='0' align="left">
                                <font>
                                    <span id='fName' style='text-decoration: none;'></span>
                                    <br><br>
                                    We've recieved a request for your password to be reset on Complete Letting Solutions. If you've not requested this then rest assured your details are safe and ignore this email!
                                    <br><br>
                                    Your Username: <span id='uName' style='text-decoration: none;'></span>
                                    <br><br>
                                    Your Password:  <span id='returnLink' style='text-decoration: none;'></span>
                                    <br><br>
                                    Please note - the password reset link above will expire in 24 hours.
                                    <br><br>
                                    <font color="#4E69B2" size="2" >
                                        <b>
                                            Kind Regards,<br>
                                            Complete Letting Solutions
                                        </b>
                                    </font>
                                </font>
                            </td>
                        </tr>
                    </table>
                    <table width='500px' border='0' cellpadding='0' cellspacing='0' style='width:500px;'>
                        <tr>
                            <td>
                                <img src='http://www.completelettingsolutions.co.uk/images/email/email_foot.jpg' border='0' />
                            </td>
                        </tr>
                    </table>
                </td>
            </tr>
        </table>
    </body>

</html>

您没有设置DOC-TYPE,因此浏览器无法知道如何阅读您的代码......