PB电子邮件,不想发送多封电子邮件-phpmailer

仓间

我想知道您是否对这个问题有想法,

我的数据库是utf8,在其中插入了这些元素

test<[email protected]>, test1<[email protected]> by SEND_EXTRA_ORDER_EMAILS_TO

我用的是Phpmailer

如果我这样做:

test<[email protected]> ==> does'nt work
[email protected], [email protected] ==> does'nt work
test<[email protected]>, test1<[email protected]>  ==> does'nt work
[email protected] ==> work

谢谢

我的功能

 function osc_mail($to_name, $to_email_address, $email_subject, $email_text, $from_email_name, $from_email_address) {
    if (SEND_EMAILS != 'true') return false;

// Instantiate a new mail object
    $message = new email(array('X-Mailer: ClicShopping Mailer'));

    // Build the text version
    $text = strip_tags($email_text);
    if (EMAIL_USE_HTML == 'true') {
      $message->add_html($email_text, $text);
    } else {
      $message->add_text($text);
    }

    // Send message
    $message->build_message();
    $message->send($to_name, $to_email_address, $from_email_name, $from_email_address, $email_subject);

    var_dump($to_email_address);// ====> See  test<[email protected]>, test1<[email protected]>
  }

并在我的文件中:

SEND_EXTRA_ORDER_EMAILS_TO正在测试,test1

  if (SEND_EXTRA_ORDER_EMAILS_TO != '') {
    $email_text_subject = stripslashes(EMAIL_TEXT_SUBJECT);
    $email_text_subject = html_entity_decode($email_text_subject);
    osc_mail('', SEND_EXTRA_ORDER_EMAILS_TO, $email_text_subject, $email_order, STORE_OWNER, STORE_OWNER_EMAIL_ADDRESS);
  }

我的课 :

 $phpMail = new PHPMailer();

  class email {
    var $html;
    var $text;
    var $html_text;
    var $lf;
    var $debug = 0;
    var $debug_output = 'error_log';

    function email($headers = '') {
      global $phpMail;

      $phpMail->XMailer = 'ClicShopping';
      $phpMail->SMTPDebug = $this->debug;
      $phpMail->Debugoutput = $this->debug_output;
      $phpMail->CharSet = CHARSET;
      $phpMail->WordWrap = 998;

      if (EMAIL_TRANSPORT == 'smtp' || EMAIL_TRANSPORT == 'gmail') {
        $phpMail->IsSMTP();

        $phpMail->Port = EMAIL_SMTP_PORT;
        if (EMAIL_SMTP_SECURE !== 'no') {
          $phpMail->SMTPSecure = EMAIL_SMTP_SECURE;
        }

        $phpMail->Host = EMAIL_SMTP_HOSTS;
        $phpMail->SMTPAuth = EMAIL_SMTP_AUTHENTICATION;

        $phpMail->Username = EMAIL_SMTP_USER;
        $phpMail->Password = EMAIL_SMTP_PASSWORD;

      } else {
        $phpMail->isSendmail();
      }

      if (EMAIL_LINEFEED == 'CRLF') {
        $this->lf = "\r\n";
      } else {
        $this->lf = "\n";
      }
    }

    function add_text($text = '') {
      global $phpMail;

      $phpMail->IsHTML(false);
      $this->text = osc_convert_linefeeds(array("\r\n", "\n", "\r"), $this->lf, $text);
    }

/**
 * Adds a html part to the mail.
 * Also replaces image names with
 * content-id's.
 */

    function add_html($html, $text = NULL, $images_dir = NULL) {
      global $phpMail;

      $phpMail->IsHTML(true);
      $this->html = osc_convert_linefeeds(array("\r\n", "\n", "\r"), '<br />', $html);
      $this->html_text = osc_convert_linefeeds(array("\r\n", "\n", "\r"), $this->lf, $text);

      if (isset($images_dir)) $this->html = $phpMail->msgHTML($this->html, $images_dir);
    }

/**
 * Adds a html part to the mail.
 * Also replaces image names with
 * content-id's.
 */

// FCKeditor
    function add_html_fckeditor($html, $text = NULL, $images_dir = NULL) {
      global $phpMail;

      $phpMail->IsHTML(true);

      $this->html = osc_convert_linefeeds(array("\r\n", "\n", "\r"), '', $html);
      $this->html_text = osc_convert_linefeeds(array("\r\n", "\n", "\r"), $this->lf, $text);

      if (isset($images_dir)) $this->html = $phpMail->msgHTML($this->html, $images_dir);
    }


    function add_attachment($path, $name = '', $encoding = 'base64', $type = '', $disposition = 'attachment') {
      global $phpMail;

      $phpMail->AddAttachment($path, $name, $encoding, $type, $disposition);
    }

    function build_message() {
      //out of work function
    }

/**
 * Sends the mail.
 */

    function send($to_name, $to_addr, $from_name, $from_addr, $subject = '', $reply_to = false) {
      global $phpMail;

      if ((strstr($to_name, "\n") != false) || (strstr($to_name, "\r") != false)) {
        return false;
      }

      if ((strstr($to_addr, "\n") != false) || (strstr($to_addr, "\r") != false)) {
        return false;
      }

      if ((strstr($subject, "\n") != false) || (strstr($subject, "\r") != false)) {
        return false;
      }

      if ((strstr($from_name, "\n") != false) || (strstr($from_name, "\r") != false)) {
        return false;
      }

      if ((strstr($from_addr, "\n") != false) || (strstr($from_addr, "\r") != false)) {
        return false;
      }

      $phpMail->From = $from_addr;
      $phpMail->FromName = $from_name;
      $phpMail->AddAddress($to_addr, $to_name);

      if ($reply_to) {
        $phpMail->AddReplyTo(EMAIL_SMTP_REPLYTO, STORE_NAME);
      } else {
        $phpMail->AddReplyTo($from_addr, $from_name);
      }

      $phpMail->Subject = $subject;

      if (!empty($this->html)) {
        $phpMail->Body = $this->html;
        $phpMail->AltBody = $this->html_text;
      } else {
        $phpMail->Body = $this->text;
      }

      if (EMAIL_TRANSPORT == 'smtp' || EMAIL_TRANSPORT == 'gmail') {
        $phpMail->IsSMTP();

        $phpMail->Port = EMAIL_SMTP_PORT;
        if (EMAIL_SMTP_SECURE !== 'no') {
          $phpMail->SMTPSecure = EMAIL_SMTP_SECURE;
        }

        $phpMail->Host = EMAIL_SMTP_HOSTS;
        $phpMail->SMTPAuth = EMAIL_SMTP_AUTHENTICATION;

        $phpMail->Username = EMAIL_SMTP_USER;
        $phpMail->Password = EMAIL_SMTP_PASSWORD;

      } else {
        $phpMail->isSendmail();
      }

      $error = false;
      if (!$phpMail->Send()) {
        $error = true;
      }

      $phpMail->clearAddresses();
      $phpMail->clearAttachments();

      if ($error == true) {
        return false;
      }

      return true;
    }
  }
亚历克斯

如果那是流行的PHPMailer https://github.com/PHPMailer/PHPMailer

您可以简单地执行以下操作:

$address = "[email protected]";
$mail->AddAddress($address, "John Doe");
$address = "[email protected]";
$mail->AddAddress($address, "John Smith");
$mail->SetFrom($from_email_address, $from_email_name);
$mail->Subject  = $email_subject;
$mail->send();

我希望那是你在找什么

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章

来自分类Dev

PHPMailer发送多封电子邮件失败

来自分类Dev

PHPMailer发送带有循环的多封电子邮件

来自分类Dev

PHPMailer发送重复的电子邮件

来自分类Dev

PHPmailer不发送电子邮件

来自分类Dev

如何使用 PHPMailer 从数据库发送多封电子邮件作为抄送?

来自分类Dev

PHPMailer - 向存储在 mySQL 数据库中的地址发送多封电子邮件

来自分类Dev

PHPMailer返回ajax错误,但仍发送电子邮件

来自分类Dev

使用PHPMailer和html模板发送html电子邮件

来自分类Dev

PHPMailer仅在SMTPDebug = true时发送电子邮件

来自分类Dev

PHPMailer电子邮件发送,但表单中没有值

来自分类Dev

PHPmailer-多次发送电子邮件

来自分类Dev

phpMailer电子邮件未发送gmail SMTP

来自分类Dev

重用PHPMailer发送第二封电子邮件吗?

来自分类Dev

使用代理IP地址从PHPMailer发送电子邮件

来自分类Dev

使用phpmailer从数据库发送电子邮件

来自分类Dev

PHPMailer发送相同的电子邮件两次

来自分类Dev

PHPMailer不发送电子邮件(如果构造)

来自分类Dev

PHPmailer-多次发送电子邮件

来自分类Dev

PHPMailer使用数组发送电子邮件

来自分类Dev

如何使用PHPMailer在电子邮件中发送图像

来自分类Dev

无法使用PHPMailer发送电子邮件

来自分类Dev

使用PHPMailer和html模板发送html电子邮件

来自分类Dev

PHPMailer主站不发送电子邮件

来自分类Dev

如何使用PhpMailer和WAMP发送电子邮件

来自分类Dev

如何通过Phpmailer发送批量电子邮件

来自分类Dev

PHPMailer & STARTTLS 不发送电子邮件

来自分类Dev

使用 PHPMailer 发送电子邮件附件

来自分类Dev

PhpMailer 不发送带有 .pdf 文件的电子邮件

来自分类Dev

phpmailer电子邮件发送不起作用

Related 相关文章

热门标签

归档