没有收到电子邮件[phpmailer]

时间:2014-08-18 14:16:58

标签: php wordpress wordpress-plugin

当有人填写表单并点击提交时,使用 phpmailer 发送电子邮件。但是,不知道为什么它不在设定地址发送电子邮件(n ***** b@gmail.com)

代码如下:

<?php 
function notifiyCustomerOnNewOrderCreation($orderDetails, $order_id = '', $update = false)
{
    global $wpdb;
    $orderHTML = makeHTMLfromOrderDetails($orderDetails);
    $order_link = admin_url('admin.php?page=cust_edit_order&id=' . str_replace("#", "*", $order_id));
    $userId = $orderDetails->OD("user_id");
    $userDetails = $wpdb->get_results("SELECT display_name,user_email FROM {$wpdb->users} WHERE ID ='{$userId}' LIMIT 1");
    global $phpmailer;
    // (Re)create it, if it's gone missing
    if ( !is_object( $phpmailer ) || !is_a( $phpmailer, 'PHPMailer' ) ) {
    require_once ABSPATH . WPINC . '/class-phpmailer.php';
    require_once ABSPATH . WPINC . '/class-smtp.php';
    $mail = new PHPMailer( true );
    } else { $mail = clone $phpmailer; }
    $mail->IsSendmail();
    if($userDetails){
    foreach($userDetails as $ca){
    try {
    $mail->AddAddress($ca->user_email, $ca->display_name);
    $mail->AddAddress('n*****b@gmail.com', 'Navnish Bhardwaj');
    if($update){
    $mail->Subject = 'Your order has been updated. ' . "[{$order_id}]";
    $mail->AltBody = 'To view the message, please use an HTML compatible email viewer!';
    $mail->MsgHTML("Your order has been updated.<br/><a href='{$order_link}'>View Order</a><br/>" . $orderHTML);
    } else {
    $mail->Subject = 'Your order has been created. ' . "[{$order_id}]";
    $mail->AltBody = 'To view the message, please use an HTML compatible email viewer!';
    $mail->MsgHTML("Your order has been created.<br/><a href='{$order_link}'>View Order</a><br/>" . $orderHTML);
    }
    $mail->Send();
    $mail->ClearAllRecipients();
    } catch(phpmailerException $e){ return false; } 
    catch(Exception $e){ return false; }
    } } return true;
}

任何建议都将不胜感激。

2 个答案:

答案 0 :(得分:0)

我并不确切地知道你要求的是什么,但我认为你想把div放在其父容器的中心。要做到这一点,div的{​​{1}}必须小于父容器的宽度(当然),它必须是width,并且display: block

您还可以在父元素上使用margin: 0 auto将元素置于display: inline-blockdisplay: inline的中心位置。这也将文本置于内部。我想这可能是你想要的,因为你说你想把所有东西都对准中心。只需将其全部放入text-align: center

例如:

div

CSS:

<div class="container">
    <div class="centerthis">
        Lorem ipsum dolor sit amet...
    </div>
</div>

OR:

.container {
}

.centerthis {
    width: 50%;
    margin: 0 auto;
}

Check out this demo to see it in action.

答案 1 :(得分:0)

您可以尝试这个来解决您的问题

在页面部分中尝试使用css
`   <style type="text/css">
       .cxxc {
          margin: 0 auto 0 0;
          border:1px solid;
        }
       .cxxc .alignCenter{
          width:100%;
          margin:0 auto 0 auto;
          border:1px solid;
          text-align:center;
       }
       #a{
          text-align:center;
          color: #80080;
          text-transform: uppercase;
          font-weight: 300;
          font-size: 24px;
          margin: 30px 0 0 0px;
       } 
    </style>    `

尝试页面正文部分中的html

<div id="a"></div>
   <br/><br/>
   <div class="cxxc">
   <div class='alignCenter'></div>
</div>

在&#39; alignCenter&#39;中输入您的所有内容div将所有数据与中心对齐