【问题标题】:GMAIL showing BCC list when sending SMTP mailGMAIL 发送 SMTP 邮件时显示密件抄送列表
【发布时间】:2012-07-05 01:07:02
【问题描述】:

我遇到了 gmail 问题,它显示发送到密件抄送列表的收件人。对此的解决方案是不在标题中包含密件抄送列表,而是将其附加到 PEAR moodule 中的收件人列表中

查看此链接 - 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@email.co.uk>";
    $from = "An Email <email@email.co.uk>";
    $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();
    }



}
?>

谢谢

安迪

【问题讨论】:

    标签: php email smtp gmail


    【解决方案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>";
        }           
    }
    ?>
    

    希望这对任何人都有帮助。

    谢谢

    安迪

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2021-12-15
      • 2011-02-01
      • 2015-12-19
      • 2012-03-20
      • 1970-01-01
      • 2017-02-09
      相关资源
      最近更新 更多