Solved

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

Posted on 2009-05-20
3
683 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 51

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 110

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 110

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

Is Your DevOps Pipeline Leaking?

Is your CI/CD pipeline a hodge-podge of randomly connected tools? You’ve likely got a tool to fix one problem & then a different tool to fix another, resulting in a cluster of tools with overlapping functionality. Learn how to optimize your pipeline with Gartner's recommendations

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
Learn the basics of lists in Python. Lists, as their name suggests, are a means for ordering and storing values. : Lists are declared using brackets; for example: t = [1, 2, 3]: Lists may contain a mix of data types; for example: t = ['string', 1, T…
Learn the basics of while and for loops in Python.  while loops are used for testing while, or until, a condition is met: The structure of a while loop is as follows:     while <condition>:         do something         repeate: The break statement m…

726 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