Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New Coder
    Join Date
    Jul 2007
    Posts
    17
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Mail delay problem

    Hi,

    I need to insert some records to a table and then need to send a mail. while using mail() function in php, it takes 20 to 25 seconds to send a mail. insert query executes immediately. but if i do any operation in the page it takes 20-25 seconds. it works properly when i get the mail.

    code which im using my page.
    $headers = "From:kamal@company.com \n";
    $headers .= "Content-Type: text/html; charset=iso-8859-1\n"; // Mime type
    $recipient = "raja@gsecone.com";
    $subject = "Test subject";
    $htmlbody = "Content text";
    mail ($recipient, $subject, $htmlbody, $headers);

    do you have any idea?

    Thanks.

  • #2
    New Coder
    Join Date
    Jul 2007
    Posts
    17
    Thanks
    0
    Thanked 0 Times in 0 Posts
    hi,

    actually i've to do two operations. one is to insert records to database (im using mysql) and another one is to send a mail to somebody.
    In my code first im using insert query then im using mail(). The problem is, while submitting my form i cann't able to do any another operation which is related to corresponding table (where i inserted records) like i cann't select particular records (using SELECT query) or i cann't show the newly added records to my list. i can do it normally when the mail will be sent. So how can i continue any operation after insert a record. that is i don't want to wait to send a mail.

    My code is
    Code: ( php )

    $qry = "insert into tbl values($val1,$val2)";
    $res = mysql_query($qry);
    if($res){
    $isadded = true;
    }
    if($isadded){
    $headers = "From:kamal@company.com \n";
    $headers .= "Content-Type: text/html; charset=iso-8859-1\n"; // Mime type
    $recipient = "raja@gsecone.com";
    $subject = "Test subject";
    $htmlbody = "Content text";
    mail ($recipient, $subject, $htmlbody, $headers);
    }

    reply me if you have any idea....

    Thanks.

  • #3
    Supreme Master coder! abduraooft's Avatar
    Join Date
    Mar 2007
    Location
    N/A
    Posts
    14,852
    Thanks
    160
    Thanked 2,223 Times in 2,210 Posts
    Blog Entries
    1
    Ensure that there is no error in the query!
    PHP Code:
    $res mysql_query($qry) or die(mysql_error()); 
    The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •