Solved

PHPMAILER: Sending mutiple Emails to different addresses with one instance/connection?

Posted on 2009-05-20
3
656 Views
Last Modified: 2013-12-12
Hi there,
I am trying to modify the phpmailer-class, so that sending multiple emails with one class instance is possible.
Problem is that the addresses add up: let's say I've got 5 different recepients, the first gets only his, the second gets the first one's and his and so on.

Any way to clear the cache after sending to one reciever?

Thx in advance
0
Comment
Question by:Merthe
  • 2
3 Comments
 
LVL 50

Accepted Solution

by:
Steve Bink earned 300 total points
ID: 24438554
There are public methods to reset the class.  I have referenced them below, direct from a new download of the PHP5/6 class.
  /**

   * Clears all recipients assigned in the TO array.  Returns void.

   * @return void

   */

  public function ClearAddresses() {

    $this->to = array();

  }
 

  /**

   * Clears all recipients assigned in the CC array.  Returns void.

   * @return void

   */

  public function ClearCCs() {

    $this->cc = array();

  }
 

  /**

   * Clears all recipients assigned in the BCC array.  Returns void.

   * @return void

   */

  public function ClearBCCs() {

    $this->bcc = array();

  }
 

  /**

   * Clears all recipients assigned in the TO, CC and BCC

   * array.  Returns void.

   * @return void

   */

  public function ClearAllRecipients() {

    $this->to = array();

    $this->cc = array();

    $this->bcc = array();

  }

Open in new window

0
 
LVL 108

Assisted Solution

by:Ray Paseur
Ray Paseur earned 200 total points
ID: 24443811
In my foreach loop, I did this.  I did not have any BCC or other things to clear.  
      $mail->ClearAddresses();

      $mail->AddAddress("$email", "$name");

Open in new window

0
 
LVL 108

Expert Comment

by:Ray Paseur
ID: 24546468
@Merthe: What was wrong with the answers that caused you to mark the grade down to a "B" ?  

Please see the grading guidelines and explain what you think we did wrong.  It costs you nothing more to give the correct grade, which in this case was "A" because you received 100% accurate answers to your question.

Thank you,
~Ray

Grading guidelines here: http://www.experts-exchange.com/help.jsp#hi403
0

Featured Post

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Foreword (July, 2015) Since I first wrote this article, years ago, a great many more people have begun using the internet.  They are coming online from every part of the globe, learning, reading, shopping and spending money at an ever-increasing ra…
This article is meant to give a basic understanding of how to use R Sweave as a way to merge LaTeX and R code seamlessly into one presentable document.
Learn the basics of if, else, and elif statements in Python 2.7. Use "if" statements to test a specified condition.: The structure of an if statement is as follows: (CODE) Use "else" statements to allow the execution of an alternative, if the …
The viewer will learn how to dynamically set the form action using jQuery.

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now