2012-07-04 85 views
2

我遇到了gmail的一個問題,它顯示發送給BCC列表的收件人。該解決方案是不包括在報頭中的BCC列表,而是其附加到收件人列表中PEAR mooduleGMAIL在發送SMTP郵件時顯示密件抄送列表

請參閱此鏈接 - http://rawphp.com/php_generator/page.php?show=PHP_Sending_Email_to_Bcc_with_SMTP_Authentication_pear_mail_factory.php

所以我已經張貼了這個給誰比誰需要知道這一點。

<?php function sendSmtpEmail($listType = 'To', $recipientList,$from,$subject = NULL,$message = NULL){ 

    require_once "Mail.php"; 

    /*$recipients = "Recipient <[email protected]>"; 
    $from = "An Email <[email protected]>"; 
    $subject = 'testing relay'; 
    $message = "<hteml><head></head><body><h1>This is a test</h1>"; 
    $message .= "<p>Paragraph</p>"; 
    $message .= "<ul><li>list item 1</li><li>List item 2</li></body>";*/ 

    $host = ini_get("SMTP"); 
    $username = NULL; 
    $password = NULL; 

    $headers['From'] = $from; 

    ///// Set to send as won't send without a to address 
    /*if($listType != 'To'){     
     $headers[$listType] = $recipientList; 
     $headers['To'] = $from; 
    } else { //// Is a to address*/ 
     $headers['To'] = ''; 
    /*}*/ 

    $recipients = $recipientList; 

    $headers['Subject'] = $subject; 
    $headers['host'] = $host; 
    $headers['MIME-Version'] = '1.0'; 
    $headers['Content-type'] = 'text/html; charset=iso-8859-1'; 
    $params['sendmail_path'] = '/usr/lib/sendmail'; 

    // Create the mail object using the Mail::factory method 
    $mail_object =& Mail::factory('sendmail', $params); 

    $mail_object->send($recipients, $headers, $message);  

    if (PEAR::isError($mail_object)) { 
     echo("<p>" . $mail_object->getMessage() . "</p>"); 
    } else { 
     echo "<p>Mail sent succefully</p>"; echo $from; echo $recipientList; die(); 
    } 



} 
?> 

感謝

安迪

回答

1

請如上見。我已經整理了功能

<?php 

function sendSmtpEmail($recipientList,$from,$subject = NULL,$message = NULL){ 

    require_once "Mail.php"; 

    $host = ini_get("SMTP"); 
    $username = NULL; 
    $password = NULL; 

    $headers['From'] = $from;  
    $headers['To'] = ''; 

    $headers['Subject'] = $subject; 
    $headers['host'] = $host; 
    $headers['MIME-Version'] = '1.0'; 
    $headers['Content-type'] = 'text/html; charset=iso-8859-1'; 
    $params['sendmail_path'] = '/usr/lib/sendmail'; 

    // Create the mail object using the Mail::factory method 
    $mail_object =& Mail::factory('sendmail', $params); 

    $mail_object->send($recipientList, $headers, $message); 

    if (PEAR::isError($mail_object)) { 
     echo("<p>" . $mail_object->getMessage() . "</p>"); 
    } else { 
     echo "<p>Mail sent succefully</p>"; 
    }   
} 
?> 

希望這可以幫助任何人。

感謝

安迪