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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T16:17:30+00:00 2026-05-11T16:17:30+00:00

Im trying to send an email to multiple addresses, so I wrote function that

  • 0

Im trying to send an email to multiple addresses, so I wrote function that pulls the emails from the database, and separates each one with a comma, but the mailing part keeps failing. However a similar function as getmails() is working on another page, so I am really lost as to what I am doing wrong. Here is my code, any help will be appreciated.

Thanks all.

function getmails()
    {
    $id = mysql_query("SELECT * FROM subscribes ORDER BY subscribe_id DESC") or die(mysql_error());
$elements = array();
while( $activeArray=mysql_fetch_array($id) )
{
    $elements[] = $activeArray['subscribe_email'] ;
}
$main = implode(', ', $elements);
print $main;

}

 function announce() {

if( isset( $_POST['announce'])) {
    $ToEmail = getmails(); 
$EmailSubject = "".$_POST['title']."";
$mailheader .= "From: newsletter@subdomain.domain.com\r\n";
$mailheader = "Reply-to:".$_POST['author']."@subdomain.domain.com\r\n";
$mailheader = "Content-type: text/html; charset=iso-8859-1\r\n";
$MESSAGE_BODY = "Author: ".$_POST['author']."<br>";
$MESSAGE_BODY = "Newsletter: ".$_POST['content']."<br>";
mail($ToEmail, $EmailSubject, $MESSAGE_BODY, $mailheader) or die ("Failure");

  }
}
  • 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-05-11T16:17:30+00:00Added an answer on May 11, 2026 at 4:17 pm

    In addition to RichieHindle’s obversation, The reason your mail is not working is because you are printing the results in the function as opposed to returning them. You should change this:

    $main = implode(', ', $elements);
    print $main;
    

    To this:

    return implode(', ', $elements);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to write a python rogram to send email to multiple addresses. Each
I am trying to send an email to multiple addresses. The code below shows
I'm trying to send multiple emails based on a boolean value in my database.
I'm trying to send an e-mail to multiple e-mail address in my database. Here
I am trying to send email using gmail from my mvc application. I am
I am trying to send email using Exchange 2007 from a console app using
I am trying to take a two text areas with multiple emails, one with
I'm trying to send email with C#. Our email provider suggested that I use
I am trying to send an email via GMail from ASP.Net using the code
I am trying to send an email to multiple users. I have a model

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.