I am developing an application for a client. What i need is, send updates with changed records to clients where the email that needs to be used is extracted from the database. What is weird is that i cant send it to all email addresses... Note that i dont have problems that emails are not delivered but it doesnt want to send it when i click send button... If i use lets say my gmail addres or couple of .com domain addresses it sends but to some other .com or .areo it doesnt... So im thinking, if it delivers to some addresses without anny problems, the script should be ok? Here is the code i use

    global $dal;

    $dal_TableName = $dal->Table("table_name");


    foreach(@$keys as $keyblock)





    $where = KeyWhere($arr2);
    $rstmp = $dal_TableName->Query($where,"");
    $datatmp=db_fetch_array($rstmp );

    $body .= "
    <style type='text/css'>
    table.email {
        border-width: 1px;
        border-spacing: 2px;
        border-style: outset;
        border-color: #cccccc;
        border-collapse: collapse;
        background-color: white;

    table.email td {
        border-width: 1px;
        padding: 5px;
        border-style: inset;
        border-color: #cccccc;
        background-color: white;
        -moz-border-radius: ;


    <table cellpadding='5' rules='all' style='border:1px solid #cccccc;' class='email'><tbody>
    <tr><td>Last Update</td><td>" . $datatmp['timestamp'] . "</td><td></td></tr>


    // send the email

    $subject="STATUS UPDATE";

    $arr = runner_mail(array('to' => $datatmp['client_email'], 'subject' => $subject,

    'htmlbody' => $body, 'charset' => 'UTF-8')); 


    $result["txt"] = "Email is sent.";

    // if error happened print a message on the web page

    if (!$arr["mailed"])


      $errmsg = "Error happened: <br>";

      $errmsg.= "File: " . $arr["errors"][0]["file"] . "<br>";

      $errmsg.= "Line: " . $arr["errors"][0]["line"] . "<br>";

      $errmsg.= "Description: " . $arr["errors"][0]["description"] . "<br>";

      $result["txt"] = $errmsg;


what else could be the problem?

Also, i need to update date and time in the database after email is sent. But im already using timestamp for recording changes when record is edited so i cant use second one. tried to set last_email_sent=now() but it doesnt work...

Anny ideas for anny of my problems?

Thank you!

4 Years
Discussion Span
Last Post by dbalas

Also, we managed to send the email once to the address which we couldnt send before, but also, couldnt send after that one time... Weird...


Well I have experienced something like this before. In my code I was using the php.mailer library. In my own case I created an application for a bank. I discovered my application was sending emails only to email address of bank staffs. It would not send to other emails like yahoo e.t.c.

Well I discovered that the php library that I used I forgot to call the smtp.class library. So not untill I imported this library, The application started sending to all emails address.

Unfortunately I dont really understand your mailing script technique but I would recommend you use the php mailer library cos it is very realiable

you can download here


documentations on how to use it is here http://phpmailer.worxware.com/

Please dont forget to call the smtp library when you are writing you codes or you might encounter what I faced.

It is very very easy to implement.


If you try this and it still does not work. Then you need to check the settings on smtp server. Maybe there could some restrictions. Well just try that library first.


Thank you for your help. I managed to find what is wrong. Problem was in MX Records. I have subdomains on my server and main email server is elsewhere so it didnt want to send mails to domains that have subdomains hosted on my server. What i needed to do is add one email address for the subdomain where the system is hosted (noreply@....) and change mx records to Remote for all subdomins hosted on my server...

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.