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 2 of 2
  1. #1
    OM2
    OM2 is offline
    New Coder
    Join Date
    Apr 2012
    Posts
    62
    Thanks
    7
    Thanked 0 Times in 0 Posts

    Trouble with email script

    I have a flash file that supplies fields to a PHP script that emails
    Everything works OK
    But... when I try sending to a second email address, it *just* doesn't work!

    The first email is sent like this:

    $ok=mail($TO,$subject,$bodyString,$header);

    I follow this up immediately by doing this:

    $ok=mail($secondemailaddress,$subject,$bodyString,$header);

    The second email just doesn't get sent!!
    I'm pulling my hair out - I've spent 2.5 hours on the damn problem!!

    I'm attaching the actual script to this post (I've made into a txt file, the forum won't allow me to upload a PHP file)
    (Actual email addresses and other names have been replaced with dummy ones)

    ALSO... if there's a better script than this one to send email, I'd appreciate if someone could give a link to

    ALSO... I have this:

    $ok=mail($TO,$subject,$bodyString,$header);

    echo "result=$ok";

    The second line send a message back to the Flash file saying that the email has been successfully sent
    Does this look OK?

    Any help or pointers would be really appreciated

    EDIT: i forgot to add, i must have the second email sent as a new email
    it's a long story - the recipients email will only receive if they are emailed directly with no other email addresses being sent to in the same email

    Thanks


    OM
    Attached Files Attached Files
    Last edited by OM2; 08-01-2012 at 03:35 AM.

  • #2
    Master Coder
    Join Date
    Jun 2003
    Location
    Cottage Grove, Minnesota
    Posts
    9,502
    Thanks
    8
    Thanked 1,089 Times in 1,080 Posts
    You're experiencing a timing problem.

    Try this ...

    PHP Code:

    if(mail($TO,$subject,$bodyString,$header)){
    // sent
    }

    if(
    mail($secondemailaddress,$subject,$bodyString,$header)){
    // sent

    What that does is, the script must finish the mail function in order to
    determine the "if" statement to be True or False. That forces it to
    complete the function before moving on. It will do that for both functions.

    See if that fixes your problem.


  •  

    Posting Permissions

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