2014-12-03 146 views
1

我試過編輯一個使用PostageAPP.com API調用的PHP郵件程序。多郵箱php郵箱

但是,當我向2個收件人發送測試郵件進行測試時,他們會看到彼此的電子郵件地址。

在文檔的網站,他們說:

As an array. This way recipients only see their own email address:

"recipients" : ["[email protected]", "[email protected]"]

但我想這不是寫在PHP。

默認的PHP代碼:

function some_func() { 
    $to = array($_POST['email'] => array('name' => $_POST['variable'])); 

    # The subject of the message 
    $subject = $_POST['subject']; 

    # Setup some headers 
    $header = array(
     'From'  => '[email protected]', 
     'Reply-to' => '[email protected]' 
    ); 

    # The body of the message 
    $mail_body = 'sample_parent_layout'; 

    # Send it all 
    $response = PostageApp::mail($to, $subject, $mail_body, $header); 
    return $response; 
} 

if (isset($_POST['email']) && $_POST['email'] !='') { 
    # Processes the form if the email has been entered (see below) 
    $response = process_submited_form(); 
} 

$api_key = (POSTAGE_API_KEY == 'ENTER YOUR API KEY HERE') ? null : POSTAGE_API_KEY 

HTML表單,我過去的電子郵件列表:

<label> To 
    <td width="41%"><font size="-3" face="Verdana, Arial, Helvetica,sans-serif"> 
    <textarea name="email" cols="30" rows="10"></textarea> 
</label> 

請幫我!我無法手動將郵件發送到每封電子郵件。

+0

:// github.com/postageapp/example-app-php/blob/master/postageapp_class.inc)?如果是這樣,你需要改變'mail'方法來考慮多個收件人。 – prodigitalson 2014-12-03 04:22:12

+0

你好,是的,我正在使用的例子。你能告訴我在這裏改變什麼嗎?如果你可以看看例子的源代碼!非常感謝 – 2014-12-03 04:24:49

回答

0

嘗試將收件人列表提交爲多陣列。

試試這個:

$to = array(
     "[email protected]" => array("name" => "John Doe"), 
     "[email protected]" => array("name" => "Jim Doe") 
); 

或者說

$to = array(
     "John Doe <[email protected]>", 
     "Jim Doe <[email protected]>" 
); 

與電子郵件地址替換你實際上是在你使用從[示例](HTTPS類的閱讀:)

+0

如果你想發送盲目拷貝,你最好打電話給PostageApp一次。 '$ recipients = explode(「\ n \ r」,$ _POST ['email']); ' 不要忘記查看每個電子郵件的$ recipients數組和filter_var以驗證用戶輸入。 – olegsv 2014-12-03 04:49:15

+0

它仍然顯示收件人郵箱上的所有電子郵件地址。 致:[email protected],[email protected] – 2014-12-03 04:52:16

+0

對不起,我猜我在寫作中間點擊了Enter。 – olegsv 2014-12-03 04:53:00