Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7886357
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T05:17:54+00:00 2026-06-03T05:17:54+00:00

I couldn’t find the answer to my specific scenario. I am developing a system

  • 0

I couldn’t find the answer to my specific scenario.

I am developing a system to send out publication to a mailing list from database. I have managed to do it using normal loop code.

However, I want to use loop only to add recipients using BCC and also maintain error handling if anyone has missed it something like:

foreach($array as $user){
    $mail->AddBCC( $user['email'], $user['customerName']);
}

try{
    $mail->AltBody    = "To view the message, please use an HTML compatible email viewer!"; // optional, comment
    $mail->AddReplyTo("noreply@company.com","Company Name");
    $mail->SetFrom('noreply@company.com', 'Company Name');
    $mail->Subject    = "Company| E-Zine";
    $mail->MsgHTML($ezineContent);              

if(!$mail->Send()) {

    //show error msg

} else {

   //show successful msg
}


}catch (phpmailerException $e) {

     //show error msg

}catch (Exception $e) {

     //show error msg
}

$mail->ClearAddresses();

Then I want to send the e-mail to all recipients added above using one call.

Is it possible to do error handling and find if anyone hasn’t received it because the address wasn’t correct??

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T05:17:55+00:00Added an answer on June 3, 2026 at 5:17 am

    A common practice of tracking the success of mailing operations is to use the “Return-Path” header of an email.

    Example of an email and its header:

    Return-Path: server@return.xyz.com
    Received: from localhost (mx-1-1 [127.0.0.1])
        by mx-1.xyz.com (Postfix) with ESMTP id 3F81556754
        for <jbradler@xyz.com>; Wed,  2 May 2012 12:27:18 +0200 (CEST)
    To: jbradler@xyz.com
    Subject: test mailing
    From: Jens <jbradler@xyz.com>
    Message-Id: <20120502102717.763ADA88004@xyz.com>
    Date: Wed,  2 May 2012 12:27:17 +0200 (CEST)
    
    Hi Folks, ...
    

    Whereby the “From” header is your choice of real name and email address that you want the reader to see, the primary purpose of the “Return-Path” is to designate the address to which messages indicating non-delivery or other mail system failures are to be sent ([see RFC 2821 for more details][1]).

    So basically this header is the right position to start fetching non-delivery reports.

    How I would do this:

    1. create a unique subdomain to fetch all non-delivery reports (e.g. return.xyz.com)
    2. set-up a inbox to catch all emails sent to the above subdomain (regardless of the local part of the email address, e.g. *@return.xyz.com)
    3. make emails unique => one recipient one unique email (no use of BCC)
    4. use recipient id (e.g. numeric id of your recipient data base) and email or campaign id to generate the local part of the future (e.g. {campaign_id}-{recipient_id})
    5. use new Return-Path: Return-Path: {campaign_id}-{recipient_id}@return.xyz.com
    6. create some tools to fetch incoming mail and filter out real non-delivery reports from SPAM and temporary notifications (e.g. out-of-office messages)

    Here an example with a unique Return-Path:

    Return-Path: 123-456@return.xyz.com
    Received: from localhost (mx-1-1 [127.0.0.1])
        by mx-1.xyz.com (Postfix) with ESMTP id 3F81556754
        for <jbradler@xyz.com>; Wed,  2 May 2012 12:27:18 +0200 (CEST)
    To: jbradler@xyz.com
    Subject: test mailing
    From: Jens <jbradler@xyz.com>
    Message-Id: <20120502102717.763ADA88004@xyz.com>
    Date: Wed,  2 May 2012 12:27:17 +0200 (CEST)
    
    Hi Folks, ...
    

    That’s it.

    Edit – How to implement that via phpMailer:

    /* define domain name for non-delivery reports */
    define('RETURN_PATH_DOMAIN', 'return.xyz.com');
    
    /* get current campaign id */
    $campaignId = 123;
    
    /* loop recipient list and send email */
    foreach ($array as $userId => $user) {
      try{
        $mail = new PHPMailer();
        $mail->HeaderLine('Return-Path', $userId . '-' $campaignId . '@' . RETURN_PATH_DOMAIN);
        $mail->To($user['email'], $user['customerName']);
        $mail->AltBody = "To view the message, please use an HTML compatible email viewer!"; 
        $mail->AddReplyTo("noreply@company.com","Company Name");
        $mail->SetFrom('noreply@company.com', 'Company Name');
        $mail->Subject = "Company| E-Zine";
        $mail->MsgHTML($ezineContent);         
        if(!$mail->Send()) {
          // show log
        } else {
          //show successful msg
        }
      } catch (Exception $e) {
        // show error
      }
    }
    

    As far as I remember we had problems by using the local sendmail. The header Return-Path was replaced by some configurations of the local MTA. If this is the case try to use SMTP to a usable relay host instead.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I couldn't find a straight answer to my question and need to know it
I couldn't find an answer anywhere on the Web, so I'm going to answer
i couldn't send data from my device to my php file. i am trying
Couldn't find an answer to this question. It must be obvious, but still. I
Couldn't find the answer by serching (maybe bad keywords), so I am creating a
I couldn't find any mapview template for the graphical layout. Mapview is from google,
I couldn't find the answer to this in any other question. Suppose that I
couldn't find an answer via search (or google) so i'll ask it myself. is
Couldn't find a clear answer to what I'm trying to achieve. I'm sure it's
Couldn't find an answer to this one. I have a WPF ListView control that

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.