邮件功能不是在php中发送正文

时间:2017-04-28 05:23:11

标签: php email

我发送带附件的电子邮件,但问题是我的邮件功能没有在电子邮件中发送body,而是将空白邮件发送到电子邮件中。

邮件代码:

if(isset($_POST['submit'])){
    if(!empty($_POST['email'])){
        $Email = $_POST['email'];
    }else{
        $_SESSION['ResultClass'] = "has-error";
        redirect($_SERVER['HTTP_REFERER']);
    }
    $File = base64_decode($_SESSION['Manual']);

    if(isset($_SESSION['Manual']) && isset($_SESSION['Name']) && isset($_SESSION['Type'])){
        $Manual = chunk_split($_SESSION['Manual']);
        $Name = $_SESSION['Name'];
        $Type = $_SESSION['Type'];
    }
    // Header
    $Headers = "MIME-Version: 1.0\r\n"; 
    $Headers .= "From:Manual <support@sensoshop.com>\r\n"; 
    //$Headers .= "Content-Type: multipart/mixed"; 
    //Attachment
    $Headers .= "Content-Type: $Type,text/html; name=".$Name."\r\n";
    $Headers .= "Content-Disposition: attachment; filename=".$Name."\r\n";
    $Headers .= "Content-Transfer-Encoding: base64\r\n";
    $Headers .= $Manual;

    // Body 
    ob_start();
    include('email/email.php');
    $Body = ob_get_contents();
    ob_end_clean();
    // Send Mail For Live
//  echo mail($Email,'asdf',base64_encode($Body),$Headers);die();
    if(mail($Email,'Words',$Body,$Headers)){
        $_SESSION['Result'] = sprintf('<div class="alert alert-success">%s</div>',"Email have been sent!");
        redirect($_SERVER['HTTP_REFERER']);
    }else{
        $_SESSION['Result'] = sprintf('<div class="alert alert-danger">%s</div>',"Something Wrong!");
        redirect($_SERVER['HTTP_REFERER']);
    }

这是我的mailer.php文件代码。我不明白为什么身体会变空。我做错了什么事。

Email.php

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width"> 
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="x-apple-disable-message-reformatting">  
    <title></title> 




    <!--[if mso]>
        <style>
            * {
                font-family: sans-serif !important;
            }
        </style>
    <![endif]-->

    <!-- All other clients get the webfont reference; some will render the font and others will silently fail to the fallbacks. More on that here: http://stylecampaign.com/blog/2015/02/webfont-support-in-email/ -->
    <!--[if !mso]><!-->
        <!-- insert web font reference, eg: <link href='https://fonts.googleapis.com/css?family=Roboto:400,700' rel='stylesheet' type='text/css'> -->
    <!--<![endif]-->

    <style>


        html,
        body {
            margin: 0 auto !important;
            padding: 0 !important;
            height: 100% !important;
            width: 100% !important;
        }

        /* What it does: Stops email clients resizing small text. */
        * {
            -ms-text-size-adjust: 100%;
            -webkit-text-size-adjust: 100%;
        }


        div[style*="margin: 16px 0"] {
            margin:0 !important;
        }


        table,
        td {
            mso-table-lspace: 0pt !important;
            mso-table-rspace: 0pt !important;
        }

        table {
            border-spacing: 0 !important;
            border-collapse: collapse !important;
            table-layout: fixed !important;
            margin: 0 auto !important;
        }
        table table table {
            table-layout: auto;
        }


        img {
            -ms-interpolation-mode:bicubic;
        }


        *[x-apple-data-detectors] {
            color: inherit !important;
            text-decoration: none !important;
        }


        .x-gmail-data-detectors,
        .x-gmail-data-detectors *,
        .aBn {
            border-bottom: 0 !important;
            cursor: default !important;
        }


        .a6S {
            display: none !important;
            opacity: 0.01 !important;
        }

        img.g-img + div {
            display:none !important;
           }


        .button-link {
            text-decoration: none !important;
        }


        @media only screen and (min-device-width: 375px) and (max-device-width: 413px) { /* iPhone 6 and 6+ */
            .email-container {
                min-width: 375px !important;
            }
        }

    </style>


    <!--[if gte mso 9]>
    <xml>
        <o:OfficeDocumentSettings>
            <o:AllowPNG/>
            <o:PixelsPerInch>96</o:PixelsPerInch>
        </o:OfficeDocumentSettings>
    </xml>
    <![endif]-->

    <!-- Progressive Enhancements -->
    <style>


        .button-td,
        .button-a {
            transition: all 100ms ease-in;
        }
        .button-td:hover,
        .button-a:hover {
            background: #555555 !important;
            border-color: #555555 !important;
        }

        /* Media Queries */
        @media screen and (max-width: 480px) {

            .fluid {
                width: 100% !important;
                max-width: 100% !important;
                height: auto !important;
                margin-left: auto !important;
                margin-right: auto !important;
            }

            .stack-column,
            .stack-column-center {
                display: block !important;
                width: 100% !important;
                max-width: 100% !important;
                direction: ltr !important;
            }

            .stack-column-center {
                text-align: center !important;
            }

            .center-on-narrow {
                text-align: center !important;
                display: block !important;
                margin-left: auto !important;
                margin-right: auto !important;
                float: none !important;
            }
            table.center-on-narrow {
                display: inline-block !important;
            }
        }

    </style>

</head>
<body width="100%" bgcolor="#222222" style="margin: 0; mso-line-height-rule: exactly;">
    <center style="width: 100%; background: #222222; text-align: left;">




        <div style="max-width: 680px; margin: auto;" class="email-container">
            <!--[if mso]>
            <table role="presentation" aria-hidden="true" cellspacing="0" cellpadding="0" border="0" width="680" align="center">
            <tr>
            <td>
            <![endif]-->

            <!-- Email Header : BEGIN -->
            <table role="presentation" aria-hidden="true" cellspacing="0" cellpadding="0" border="0" align="center" width="100%" style="max-width: 680px;">
                <tr>
                    <td style="padding: 20px 0; text-align: center">
                        <img src="../inc-media/logo.png" aria-hidden="true" width="200" height="50" alt="alt_text" border="0" style="height: auto;  font-family: sans-serif; font-size: 15px; line-height: 20px; color: #555555;">
                    </td>
                </tr>
            </table>
            <!-- Email Header : END -->

            <!-- Email Body : BEGIN -->
            <table role="presentation" aria-hidden="true" cellspacing="0" cellpadding="0" border="0" align="center" width="100%" style="max-width: 680px;">



                <!-- 1 Column Text + Button : BEGIN -->
                <tr>
                    <td bgcolor="#ffffff">
                        <table role="presentation" aria-hidden="true" cellspacing="0" cellpadding="0" border="0" width="100%">
                            <tr>
                                <td style="padding: 40px 40px 20px; text-align: left;">
                                    <h1 style="margin: 0; font-family: sans-serif; font-size: 24px; line-height: 27px; color: #333333; font-weight: normal;">Dear <?php echo $Email; ?>.</h1>
                                </td>
                            </tr>
                            <tr>
                                <td style="padding: 0 40px 40px; font-family: sans-serif; font-size: 15px; line-height: 20px; color: #555555; text-align: left;">
                                    <p style="margin: 0;">Thank you for visiting Sensoshop.com. Please find your selected user guide attached to this email.</p>                    <ul>
                                 <li>Register your product and instantly get 18 months of warranty extension at <br />
                                 <a href="http://sensoshop.com/warranty">sensoshop.com/warranty</a></li>    
                                </ul>
                                <br>
                                <strong>Regards</strong>,<br>
                        SensoShop
                                </td>
                            </tr>


                        </table>
                    </td>
                </tr>






                <!-- 1 Column Text : END -->

            </table>
            <!-- Email Body : END -->

            <!-- Email Footer : BEGIN -->
            <table role="presentation" aria-hidden="true" cellspacing="0" cellpadding="0" border="0" align="center" width="100%" style="max-width: 680px;">
                <tr>
                    <td style="padding: 40px 10px;width: 100%;font-size: 12px; font-family: sans-serif; line-height:18px; text-align: center; color: #888888;" class="x-gmail-data-detectors">

                        At Sunvalleytek we never sell, rent, or share your information with any third party.<br>
You may also receive emails from our associate brands,-RAVPower, HooToo, TaoTronics, VAVA etc..<br>
To stop receiving these emails<br>
                        <br>
                        <unsubscribe style="color:#888888; text-decoration:underline;">unsubscribe</unsubscribe>
                    </td>
                </tr>
            </table>
            <!-- Email Footer : END -->

            <!--[if mso]>
            </td>
            </tr>
            </table>
            <![endif]-->
        </div>
    </center>
</body>
</html>

0 个答案:

没有答案