89273

PHPMailer , keep 1 SMTP Connection with different receiver by email content

Question:

$phpMailer = New PHPMailer(); $phpMailer->isSMTP(); $phpMailer->SMTPKeepAlive = true; for ( ... ) { // Send your emails right away [ ... ] } $phpMailer->SmtpClose();

HI, I have an example code for KeepAlive SMTP here, but my problem is I send email with difference contents to my users. So each user have 1 content.

Can I do it like this:

for ( ... ) { $phpMailer->addAddress($user['email'], $user['name']); $phpMailer->Subject = $user['subject']; $phpMailer->Body = $user['body']; $phpMailer->Send() }

Will the ->addAddress increase my recipients every time on the loop? Or will it clean the old recipient after ->send() comitted ?

Answer1:

Call clearAddresses() Before addAddress function . It is cleared before recipients.

$phpmailer->ClearAddresses(); $phpMailer->addAddress($user['email'], $user['name']);

Recommend

  • GCP load balancer 502 server error and “backend_connection_closed_before_data_sent_to_client” IIS 10
  • Jenkins ssh slave disconnect to make the task continue perform
  • What determines whether NavigationCommands.BrowseBack calls the page constructor?
  • zend smtp mail crashes after 100+ mails
  • Image in Email Subject using PHP
  • How to configure Monolog to send errors via SwiftMailer to alternate mailer in Symfony2
  • SmtpClient sends email to junk
  • WP7 difficulties binding data to listbox itemssource - won't refresh
  • Ruby 1.8.6 Array#uniq not removing duplicate hashes
  • Configure Spring's MappingJacksonHttpMessageConverter
  • encoding issues with content in response from HttpWebRequest
  • AppleScript : find open tab in safari by name and open it
  • Java color detection
  • zope_i18n_compile_mo_files doesn't work on a Zeo configuration
  • OOP Javascript - Is “get property” method necessary?
  • How do I access an unhandled exception in an MVC Error view?
  • Email verification using google app script and google forms
  • Scrapy recursive link crawler
  • Email format validation in mvc3 view
  • C# - Is there a limit to the size of an httpWebRequest stream?
  • How to make a tree having multiple type of nodes and each node can have multiple child nodes in java
  • Updating server-side rendering client-side
  • Cassandra Data Model
  • Join two tables and save into third-sql
  • sending/ receiving email in Java
  • How to model a transition system with SPIN
  • ORA-29908: missing primary invocation for ancillary operator
  • How to pass list parameters for each object using Spring MVC?
  • Codeigniter doesn't let me update entry, because some fields must be unique
  • Acquiring multiple attributes from .xml file in c#
  • How to CLICK on IE download dialog box i.e.(Open, Save, Save As…)
  • Authorize attributes not working in MVC 4
  • How can I remove ASP.NET Designer.cs files?
  • sending mail using smtp is too slow
  • Busy indicator not showing up in wpf window [duplicate]
  • How to get NHibernate ISession to cache entity not retrieved by primary key
  • Converting MP3 duration time
  • Python/Django TangoWithDjango Models and Databases
  • java string with new operator and a literal
  • Net Present Value in Excel for Grouped Recurring CF