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

  • Home
  • SEARCH
  • 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 8672457
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T19:12:32+00:00 2026-06-12T19:12:32+00:00

Resolved: After installing PHPMailer it now works. I am trying to use MIME E-mail

  • 0

Resolved: After installing PHPMailer it now works.


I am trying to use MIME E-mail to send out mail to a large number of members.
Seeing that my web-host has limitations on how long a function can run on their server I had to adjust the old functionality.
This is how I want it to work:

  1. Get every member email-address from database table and create a new table with all of these email-addresses.
  2. In the new table I also create two attributes called “Sent” and “Error”.
  3. I am planning to use Cron on this functionality. So that every row of email-addresses eventually will be set with Sent = True(1) or Error = True (1).

There is only one problem. I tried testing this on 4 email-addresses. When one of them returns error all the following email-addresses get the same error.

Example of error messages:

Error: 501 : malformed address: �> may not follow **Probably caused of ÆØÅ**
Error: 501 : domain missing or malformed  **Because @service.com is missing**

etc..

Output example:

1: Before function. Error value: 
1: After function. Error value: 501 : domain missing or malformed
2012-10-10 20:07:46 : 1: MemberID: 1, Mail:testme
Error: 501 : domain missing or malformed 

2: Before function. Error value: 
2: After function. Error value: 501 : domain missing or malformed
2012-10-10 20:07:46 : 2: MemberID: 2, Mail:testme@gmail.com
Error: 501 : domain missing or malformed 

3: Before function. Error value: 
3: After function. Error value: 501 : domain missing or malformed
2012-10-10 20:07:46 : 3: MemberID: 3, Mail:testme@hotmail.com
Error: 501 : domain missing or malformed* 

I can’t understand why this happens.

######################################
### START NEW MAIL FUNCTION   ####
######################################
##############################################
### Deletes table if already exists   ####
##############################################


$dropExistingTable = "DROP TABLE IF EXISTS $databaseTableNameContainingMembers";
mysql_query($dropExistingTable) or die(mysql_error());

####################################
### Creating new table  ####
####################################
$queryCreateTable = "CREATE TABLE $databaseTableNameContainingMembers(ID mediumint(6) NOT NULL AUTO_INCREMENT, Mail TEXT, MailSent BOOLEAN DEFAULT 0, Error BOOLEAN DEFAULT 0, PRIMARY KEY (ID))";
mysql_query($queryCreateTable) or die(mysql_error());

####################################
### Filling new table   ####
####################################
//Now we fill the new table with all our members (MemberID, Mail, Sendt = 0).

while ($medlem = mysql_fetch_array($query_medlem)) {
    //insert all member mails to new table
    $memberMail = $medlem["Epost"];
    $queryInsertMemberToNewTable = "INSERT INTO $databaseTableNameContainingMembers (`Mail`) VALUES ('" . $memberMail . "')";
    mysql_query($queryInsertMemberToNewTable) or die(mysql_error());
}

######################################
### Sending function      ####
######################################

function sendMail($table, $email_message) {
##########################################
###     Selecting the new table       ####
##########################################
    $querySelectAllMembersThatHasNotAlreadyBeenSentTo = "SELECT * FROM $table WHERE `MailSent` = 0 AND `Error` = 0";

//Selects all members that havent been sendt mail to yet.

    $allMembersThatHasNotAlreadyBeenSentTo = mysql_query($querySelectAllMembersThatHasNotAlreadyBeenSentTo) or die("Problem with selecting table. <br>" . mysql_error());

    $i = 1;
    while ($row = mysql_fetch_array($allMembersThatHasNotAlreadyBeenSentTo)) {

        $to_address = $row["Mail"];
        $memberId = $row["ID"];

       $email_message->SetEncodedEmailHeader("To", $to_address, ""); 

        $error = "";
        echo $i . ": Before function. Error value: " . $error . "</br></br>";
        $error = $email_message->Send();
        echo $i . ": After function. Error value: " . $error . "</br></br>";
        echo "</br>";

        if (strcmp($error, "") > 0) {
            ##########################################################
            ###      IF ERROR UPDATE MEMBER VARIABLE "Error"      ####
            ##########################################################
            updateErrorToMember($memberId, $table, 1);
            echo date("Y-m-d H:i:s") . " : " . $i . ": MemberID: " . $memberId . ", Mail:" . $to_address . "</br>Error: $error </br></br></br>";
        } else {
            ##################################################################
            ###    IF SENDING SUCCEEDS UPDATE MEMBER VARIABLE "Sent"      ####
            ##################################################################
            updateSentToMember($memberId, $table);
            echo date("Y-m-d H:i:s") . ": " . $i . " :  Message sent to $to_address<br></br>";
        }
        $i++;
    } //while
}//function

######################################
###    End of sending function    ####
######################################
######################################
###     Run sending function      ####
######################################
sendMail($databaseTableNameContainingMembers, $email_message);
  • 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-12T19:12:33+00:00Added an answer on June 12, 2026 at 7:12 pm

    You are not clearing the $email_message object after each send, you are using the same $email_message object, just appending new addresses and sending, if one of those addresses are incorrect you carry on the error to the following recipients.

    You could try replacing your following code:

    $email_message->SetEncodedEmailHeader("To", $to_address, "");
    

    for this one:

    $email_message->ClearAddresses();
    $email_message->AddAddress($to_address, $to_address);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying out magnolia (v 4.4.6) with blossom (v.1.2.3) for spring integration. After installing
I know that I should use git add after the conflict is resolved. I've
After installing .NET 4.5, any users accessing the Workbox now receive an exception: Object
How can I resolved this error that I see in Gradle after upgrading to
After a merge I want to use git mergetool to resolve the issue but
I resolved a code issue with a gem, but how do I then use
I resolved this issue myself. It turns out that the activation framework requires some
I had this same problem last week, which resolved itself after I enabled impersonation.
After recently installing Windows 7 Professional, I'm getting a strange problem removing a TableItem
After installing the Shiro plugin (v 1.1.3) in a Grails (v 1.3.7) application and

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.