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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T14:40:23+00:00 2026-05-30T14:40:23+00:00

I have the following code, which sends emails but it is embedding one email

  • 0

I have the following code, which sends emails but it is embedding one email in another instead of sending them separately, the output is also below.

Any thoughts?

H.

Email output

SMTP Test Email Message

Dear Gary,

Dear Jaime,

Test Message

Here is a quick email test to see what it comes through like. Link: = 

Test

Does it do formatting correctly and what is the situation with dual = names appearing etc?

Kind regards,

Gary. 
 Link: http:// 

Test

Does it do formatting correctly and what is the situation with dual names appearing etc?

Kind regards,

Gary.

Code snippet

do {
    $dear = "<font face='Arial' size='2'>Dear " . $row["forename"] . ",<br><br></font>";

    $email_body = $dear . "<font face='Arial' size='2'>" . stripslashes($body) . "</font><br><br><font face='Arial' size='2'>" . $linky . "  <a href='" . $row["link"] . "'> " . $row["link"] . "</a> </font> <br><br><font face='Arial' size='2'>" . stripslashes($body2) . "</font>";

    $subject = $sub;

$bcc = "blob.blob@blob.co.uk";
$recipients = $row["email"].",".$bcc;
// Constructing the email
$sender = $bcc;                                             
$recipient = $recipients;                               
$subject = $subject;                                                

$html = $email_body;      
$crlf = "\n";
    $headers = array(
        'To'        => $row["Mail"],
        'From'          => $sender,
        'Return-Path'   => $sender,
        'Subject'       => $subject
                     );

// Creating the Mime message
$mime = new Mail_mime($crlf);

// Setting the body of the email
//$mime->setTXTBody($text);
    $mime->setHTMLBody($html);


// Set body and headers ready for base mail class
$body = $mime->get();
$headers = $mime->headers($headers);

// SMTP authentication params
$smtp_params["host"]     = "scr.emserv.com";
$smtp_params["port"]     = "25";
$smtp_params["auth"]     = true;
$smtp_params["username"] = "blob.blob@blob.co.uk";
$smtp_params["password"] = "blob";

// Sending the email using smtp
$mail =& Mail::factory("smtp", $smtp_params);
sleep(2);
$result = $mail->send($recipient, $headers, $body);

for($i=0;$i<$elements1;$i++){
$bar1->increase(); //calls the bar with every processed element
$bar1->setMessage('Sending emails (2 second delay between each): '.(($i+1)*$sent).'%');

}

if($row["sent"]=='YES'){
$reminder = $row["reminder"] + 1;
$update = mysql_query("UPDATE $table SET reminder = $reminder WHERE respondent_id = " . $row["respondent_id"] . " ") or die("Could not update record<br>".mysql_error());
}else

$update = mysql_query("UPDATE $table SET sent = 'YES' WHERE respondent_id = " . $row["respondent_id"] . " ") or die("Could not update record<br>".mysql_error());

} while ($row = mysql_fetch_assoc($results));
    $bar1->setMessage('Emails have now been sent: 100%');
    }
  • 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-30T14:40:25+00:00Added an answer on May 30, 2026 at 2:40 pm

    The reason you’re seeing this issue is that you’re not clearing the $body variable. Every time through the loop it is basically appending it to the $email_body variable in this line:

    $email_body = $dear . "<font face='Arial' size='2'>" . stripslashes($body) ...

    Farther down you set $body to the entire message:

    $body = $mime->get();

    get() returns the entire message as a string. It also doesn’t make sense that you would be utilizing $body originally since it’s not initialized in this do while loop until after the first line I listed.

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

Sidebar

Related Questions

I have the following code which handles files upload on the server. But how
I have the following code which works fine, but it doesn't send the attachment
I have some Java code which sends out an email with code somewhat like
I'm trying to use opengl in C#. I have following code which fails with
I have following Code Block Which I tried to optimize in the Optimized section
I have the following code which works just fine when the method is POST,
I have the following code which works fine. However, I only want to return
I have the following code which should put programs startable in Bash. if [
I have the following code which reads in the follow file, append a \r\n
I have the following code which re-uses a CookieContainer which logs in on the

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.