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 8253113
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T00:45:52+00:00 2026-06-08T00:45:52+00:00

I have an array of emails and want to send an email for each

  • 0

I have an array of emails and want to send an email for each entry in the array but currently it only sends it to the first address. I have looked around and can’t see what I am doing wrong.

//This is the array
$emails = array($teamleademail, $coleademail, $sponsoremail, $facilitatoremail, $cisupportemail);

//Now the foreach statment    
foreach ($emails as $value) {
    //pulls in email sending code
    require_once ("Mail.php");
    //variables required to send the email 
     $from = "Scope Sheet Process Database (no reply)<scopesheetprocess@goodrich.com>";
     //Make the $to variable that of the email in the array
     $to = "$value";
     $subject = "Scope Sheet $scopesheetid Closed";
     $body = "Scope Sheet $scopesheetid has been closed and can no longer be edited.";
     //send email code
     require_once ("sendemail.php");
}  

I am using pear php to send the email because of IT issues but that shouldn’t matter since it should be running the scripts each time and sending separate emails.

  • 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-08T00:45:54+00:00Added an answer on June 8, 2026 at 12:45 am

    The problem is this line:

    require_once ("sendemail.php");
    

    …should just be

    require ("sendemail.php");
    

    As it is, it will only be included on the first iteration of the loop, hence only the first email is sent.

    This on its own may not fix your problem – if it doesn’t we’ll need to see the code in sendemail.php.

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

Sidebar

Related Questions

I want to send an email with a variable name. I have created the
So I have a contact field which sends an email when submitted, I want
Let's say I have this array, $array = array( 'name' => 'hermet', 'emails' =>
I have an array of input strings that contains either email addresses or account
I have a json array with certain objects : first name , last name,
I have about 50 users in a database and I want to send them
I'm currently using SwiftMailer to send out emails to several users (up to 50).
I have a console application that sends customized emails (with attachments) to different recipients
I'm using phpmailer to send emails to addresses stored in the variable $to, but
I have an array like this array([0]=> 'email@email.com', [1]=> 'email2@email.com', [2]=> 'email3@email.com'); I also

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.