php
  • email
  • content-type
  • oscommerce
  • 2013-11-25 2 views 0 likes 
    0

    oscommerce에서 얼마나 많은 제품을 구매했는지에 따라 여러 개의 이메일을 발송하는 기능이 있습니다. 함수의 php mail() 부분에 헤더를 추가 할 때까지 잘 작동합니다. 당신이 울부 짖는 볼 수 있듯이, 내 헤더 읽기 :

    $headers .= 'MIME-Version: 1.0' . "\r\n"; 
        $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; 
    
        $headers .= "From: [email protected] \r\n" . 
          "Reply-To: [email protected] \r\n" . 
          "X-Mailer: PHP/" . phpversion(); 
    

    을하지만 (내가 HTML로 이메일을 보내기 위해 필요) 헤더를 선언 할 때, 첫 번째 메일이 발송됩니다. 헤더를 여러 번 보낼 수 없습니까? 모든 제안을 부탁드립니다!

    기능 조각 :

    foreach ($dstToProduct as $dsid => $productIndices) { 
        $email = $newDropships[$dsid]['email']; 
        $subject = "A new order has been placed"; 
        $headers .= 'MIME-Version: 1.0' . "\r\n"; 
        $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; 
    
        $headers .= "From: [email protected] \r\n" . 
          "Reply-To: [email protected] \r\n" . 
          "X-Mailer: PHP/" . phpversion(); 
    
    
    
    
        // Build message text 
        $date = date('m/d/Y'); 
    
        $text = '<table cellpadding="3" style="margin-top: 20px;"><tr style="background-color: #6d7d59; color: #ffffff; font-weight: bold; font-size: 12px;"><td style="width: 240px; vertical-align:text-top;">Product Name</td><td style="width: 120px; vertical-align:text-top;">Model Number</td><td style="width: 80px; vertical-align:text-top;">Quantity</td><td style="width: 80px; vertical-align:text-top;">Price</td></tr>'; 
    
        foreach ($productIndices as $productIndex) { 
    
          $text .= '<tr style="background-color: #f0f0f0; color: #513311; font-size: 12px;"><td style="vertical-align:text-top;">' . $products_array[$productIndex]["text"] . '</td><td style="vertical-align:text-top;">' . $products_array[$productIndex]["model"] . '</td><td style="vertical-align:text-top;">' . $products_array[$productIndex]["qty"] . '</td><td style="vertical-align:text-top;">' . $products_array[$productIndex]["price"] . '</td></tr>'; 
    
        } 
    
         $text .= '</table>'; 
    
    
        if (!mail($email, $subject, $text, $headers)) { 
         mail('[email protected]', 'Error sending product', 'The following order was not sent:&nbsp;' . $order_id); 
        } 
    
    } 
    } 
    
    +0

    (첫번째 메일을 보낸 후) 당신은 어떤 오류가? – MeNa

    +0

    오류가 발생하지 않으며 오류 로그에서 아무 것도 찾을 수 없습니다. 루프를 멈추는 것처럼 보입니다. –

    답변

    2

    이 시도 :

    $subject = "A new order has been placed"; 
    $headers = 'MIME-Version: 1.0' . "\r\n"; 
    $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; 
    $headers .= 'From: Info <[email protected]>' . "\r\n"; 
    $headers .= 'Reply-To: Info <[email protected]>' . "\r\n"; 
    $headers .= "X-Mailer: PHP/".phpversion(); 
    $date = date('m/d/Y'); 
    foreach ($dstToProduct as $dsid => $productIndices) 
    { 
    $email = $newDropships[$dsid]['email']; 
    $text = '<table cellpadding="3" style="margin-top: 20px;"><tr style="background-color: #6d7d59; color: #ffffff; font-weight: bold; font-size: 12px;"><td style="width: 240px; vertical-align:text-top;">Product Name</td><td style="width: 120px; vertical-align:text-top;">Model Number</td><td style="width: 80px; vertical-align:text-top;">Quantity</td><td style="width: 80px; vertical-align:text-top;">Price</td></tr>'; 
    
        foreach ($productIndices as $productIndex) { 
    
        $text .= '<tr style="background-color: #f0f0f0; color: #513311; font-size: 12px;"><td style="vertical-align:text-top;">' . $products_array[$productIndex]["text"] . '</td><td style="vertical-align:text-top;">' . $products_array[$productIndex]["model"] . '</td><td style="vertical-align:text-top;">' . $products_array[$productIndex]["qty"] . '</td><td style="vertical-align:text-top;">' . $products_array[$productIndex]["price"] . '</td></tr>'; 
    
        } 
    $text .= '</table>'; 
    if (!mail($email, $subject, $text, $headers)) { 
        mail('[email protected]', 'Error sending product', 'The following order was not sent:&nbsp;' . $order_id); 
    } 
    

    }

    1

    당신은 당신의 $ 헤더 루프와 병합되어

    가 당신을 위해 일해야 희망이 ...

    <?php 
        $headers=array(
         'MIME-Version: 1.0' . "\r\n", 
         'From: [email protected]', 
         'Content-Type:text/html', 
         'Reply-To: [email protected]' 
        ); 
        $subject = "A new order has been placed"; 
    
        foreach ($dstToProduct as $dsid => $productIndices) { 
         $email = $newDropships[$dsid]['email']; 
    
    
        // Build message text 
         $date = date('m/d/Y'); 
    
         $text = '<table cellpadding="3" style="margin-top: 20px;"><tr style="background-color: #6d7d59; color: #ffffff; font-weight: bold; font-size: 12px;"><td style="width: 240px; vertical-align:text-top;">Product Name</td><td style="width: 120px; vertical-align:text-top;">Model Number</td><td style="width: 80px; vertical-align:text-top;">Quantity</td><td style="width: 80px; vertical-align:text-top;">Price</td></tr>'; 
    
         foreach ($productIndices as $productIndex) { 
    
         $text .= '<tr style="background-color: #f0f0f0; color: #513311; font-size: 12px;"><td style="vertical-align:text-top;">' . $products_array[$productIndex]["text"] . '</td><td style="vertical-align:text-top;">' . $products_array[$productIndex]["model"] . '</td><td style="vertical-align:text-top;">' . $products_array[$productIndex]["qty"] . '</td><td style="vertical-align:text-top;">' . $products_array[$productIndex]["price"] . '</td></tr>'; 
    
         } 
    
         $text .= '</table>'; 
         $body = $text; 
    
    
        if (!mail($email,$subject,$body,implode("\r\n",$headers))) { 
          mail('[email protected]', 'Error sending product', 'The following order was not sent:&nbsp;' . $order_id); 
         } 
    
    
        } 
    
    0

    같은 시도 할 수 있습니다, 이 시도. 나는 그것이 작동 확신 :

    foreach ($dstToProduct as $dsid => $productIndices) { 
        $email = $newDropships[$dsid]['email']; 
        $subject = "A new order has been placed"; 
    
        $headers = ""; 
    
        $headers .= 'MIME-Version: 1.0' . "\r\n"; 
        $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; 
    
        $headers .= "From: [email protected] \r\n" . 
          "Reply-To: [email protected] \r\n" . 
          "X-Mailer: PHP/" . phpversion(); 
    
    
    
    
        // Build message text 
        $date = date('m/d/Y'); 
    
        $text = '<table cellpadding="3" style="margin-top: 20px;"><tr style="background-color: #6d7d59; color: #ffffff; font-weight: bold; font-size: 12px;"><td style="width: 240px; vertical-align:text-top;">Product Name</td><td style="width: 120px; vertical-align:text-top;">Model Number</td><td style="width: 80px; vertical-align:text-top;">Quantity</td><td style="width: 80px; vertical-align:text-top;">Price</td></tr>'; 
    
        foreach ($productIndices as $productIndex) { 
    
          $text .= '<tr style="background-color: #f0f0f0; color: #513311; font-size: 12px;"><td style="vertical-align:text-top;">' . $products_array[$productIndex]["text"] . '</td><td style="vertical-align:text-top;">' . $products_array[$productIndex]["model"] . '</td><td style="vertical-align:text-top;">' . $products_array[$productIndex]["qty"] . '</td><td style="vertical-align:text-top;">' . $products_array[$productIndex]["price"] . '</td></tr>'; 
    
        } 
    
         $text .= '</table>'; 
    
    
        if (!mail($email, $subject, $text, $headers)) { 
         mail('[email protected]', 'Error sending product', 'The following order was not sent:&nbsp;' . $order_id); 
        } 
    
    } 
    } 
    
    1

    당신이 phpversion는() 문제를 상승이 같은 시도라고 생각하는 경우 :

    $phpV = phpversion(); 
        $subject = "A new order has been placed"; 
        $headers .= 'MIME-Version: 1.0' . "\r\n"; 
        $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; 
        $headers .= "From: [email protected] \r\n" . 
           "Reply-To: [email protected] \r\n" . 
           "X-Mailer: PHP/" .$phpV; 
    

    을 그리고 일반적으로, 당신은이 작업을 수행 할 필요가 없습니다 매번 특정 사용자가 아닌 변수가 달라집니다. 한 번 선언 할 수 있습니다. 이 같은 :

    $subject = "A new order has been placed"; 
    $headers .= 'MIME-Version: 1.0' . "\r\n"; 
    $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; 
    
    $headers .= "From: [email protected] \r\n" . 
         "Reply-To: [email protected] \r\n" . 
         "X-Mailer: PHP/" . phpversion(); 
    
    $date = date('m/d/Y'); 
    
    $text = '<table cellpadding="3" style="margin-top: 20px;"><tr style="background-color: #6d7d59; color: #ffffff; font-weight: bold; font-size: 12px;"><td style="width: 240px; vertical-align:text-top;">Product Name</td><td style="width: 120px; vertical-align:text-top;">Model Number</td><td style="width: 80px; vertical-align:text-top;">Quantity</td><td style="width: 80px; vertical-align:text-top;">Price</td></tr>'; 
    foreach ($productIndices as $productIndex) { 
        $text .= '<tr style="background-color: #f0f0f0; color: #513311; font-size: 12px;"><td style="vertical-align:text-top;">' 
        . $products_array[$productIndex]["text"] . '</td><td style="vertical-align:text-top;">' 
        . $products_array[$productIndex]["model"] . '</td><td style="vertical-align:text-top;">' 
        . $products_array[$productIndex]["qty"] . '</td><td style="vertical-align:text-top;">' 
        . $products_array[$productIndex]["price"] . '</td></tr>'; 
    } 
    $text .= '</table>'; 
    
    foreach ($dstToProduct as $dsid => $productIndices) { 
        $email = $newDropships[$dsid]['email']; 
        if (!mail($email, $subject, $text, $headers)) { 
         mail('[email protected]', 'Error sending product', 'The following order was not sent: ' . $order_id); 
        } 
    
    관련 문제