开发者

PHP mailer containing HTML not showing correctly

here is some code I've been working on, basically I need to set up a auto e-mail that gets sent to a user after they fill in a form, which at the moment it is doing, but the HTML is not displaying as it should inside of the email client.

I checked in Gmail, Outlook and Mac mai开发者_如何学运维l and none of them display the HTML correctly.

Here is the code

<?php
    session_start();
    $_SESSION['name'] = $_POST['name'];
    $name = $_SESSION['name'];
    $email_1 = $_POST['email_1'];
    $email_2 = $_POST['email_2'];
    $email_3 = $_POST['email_3'];
    $email_4 = $_POST['email_4'];
    $id_num = $_POST['id_num'];
    $tel = $_POST['tel'];
    $email = $_POST['email'];



    //sets the current date

    $curDate = date("Y-m-d");

    // Example


    require_once("mailclass/htmlMimeMail.php");
    $mail = new htmlMimeMail();
    $mail->setSubject("Your submission to MyWebsite!");
    $mail->setFrom("MyWebsite <info@website.co.za>");
    $mail->setFrom("MyWebsite <info@website.co.za>");
    $email_address = $email_1 . "," . $email_2 . "," . $email_3 ."," . $email_4 ;
    $mail->setBcc($email_address);





    $day = "
         <body style="'background: #000000; color: #FFFFFF;'">
         <div style="'background-image: url(http://www.website.com/images/mailerbg.jpg); width: 900px; height: 839px; margin: 0 auto;'">
         <div style="'width: 620px; height: 280px; position: relative; top: 155px; left: 25px;'">
                <h1><br>your friend $name<br><br><br></h1>
            </div>    
        </div>
        </body>";

    $mail->setHTML($day);   
            $result = $mail->send(array());

    ?> 

The code is pretty messy, from me screwing around with it so much, but basically none of the HTML shows up as it should in the email client once the message arrives at it's destination, how can I get it to display as a proper HTML page inside of the mail client?

I am assuming that my escaping is not done correctly, which is why nothing is showing as it should?

Thanx in advance!


Showing the PHP code is useless in this case. We need to see a final, generated E-Mail.

What catches the eye, though, is some faulty quoting:

 <body style="'background: #000000; color: #FFFFFF;'">

should be

 <body style="background: #000000; color: #FFFFFF;">

Maybe that fixes it already.

In addition, according to this great guide, positioning is hardly supported in E-Mails - this could disturb the layout as well.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜