OM2 Posted August 1, 2012 Share Posted August 1, 2012 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 (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 Thanks OM 18748_.php Quote Link to comment https://forums.phpfreaks.com/topic/266524-trouble-with-email-script/ Share on other sites More sharing options...
OM2 Posted August 1, 2012 Author Share Posted August 1, 2012 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 Quote Link to comment https://forums.phpfreaks.com/topic/266524-trouble-with-email-script/#findComment-1365871 Share on other sites More sharing options...
PFMaBiSmAd Posted August 1, 2012 Share Posted August 1, 2012 Your code is likely triggering some relaying restrictions on your email server, if the to/from address is not hosted on the email server. In your code you are putting the second email address into both the to and from addresses, whereas the 'working' email has a different from address. The email is being sent from your mail server. It is not being sent from the second email address. I recommend the following - 1) $HTTP_POST_VARS were depreciated about 10-11 years ago; were turned off by default in php5.0; finally throw a deprecated error in php5.3 (where the deprecated error category was introduced), and have been completely removed in php5.4. You need to use $_POST in place of $HTTP_POST_VARS. 2) You need to make a html form that submits the expected $_POST data for testing purposes so that you can easily see all the output being sent back from the server side form processing code. 3) You need to have php's error_reporting set to E_ALL and display_errors set to ON so that php will help you by reporting and displaying all the errors it detects. 4) Echoing the value that the mail() statement returns will show a '1' for a true value, but won't show anything for a false value (I thinks a false, treated as a string, becomes an empty string '' when you echo it). Your program logic should have an if/else statement testing the value that the mail() statement returns and output (or log) a specific value/message when the mail statement fails. 5) After you do items #2 and #3, see if you get any php errors being output from the mail() statement(s). 6) I would make the FROM address in the second email exactly the same as your first working email. I'm not sure why you changed anything other than the TO: parameter. Quote Link to comment https://forums.phpfreaks.com/topic/266524-trouble-with-email-script/#findComment-1365954 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.