Jump to content

Recommended Posts

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

Link to comment
https://forums.phpfreaks.com/topic/266524-trouble-with-email-script/
Share on other sites

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.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.