Jump to content


Photo

mail() sends one email but not the other...why?


  • Please log in to reply
8 replies to this topic

#1 simcoweb

simcoweb
  • Members
  • PipPipPip
  • Advanced Member
  • 1,102 posts
  • LocationCA

Posted 18 October 2006 - 07:20 PM

I have a contact form that when submitted would send the visitor a confirmation email containing the form info they completed. It also sends an email containing the form info to the member designated by their ID number. It's sending the confirmation email but not the email to the member. Here's the code:

<?php// start mail process
$mailContent="--------CONTACT--------\n"
            ."Name: ".$name."\n"
            ."Location: ".$location."\n"
            ."E-mail: ".$email."\n\n--------PHONE--------\n"
            ."Phone: ".$phone."\n"
            ."Best time to call: ".$best_time."\n\n--------Details--------\n"
            ."Details: ".$details."\n";
//----------------------------------
$toAddress="" . $row['email'] . ""; /* change this! */
$subject="Plateau Professionals Referral"; /* change this! */
$recipientSubject="Plateau Professionals Confirmation"; /* change this! */
$receiptMessage = "Thank you ".$name." for inquiring at PlateauProfessionals.com's website!\n\n\nHere is what you submitted to us:\n\n"
            ."--------CONTACT--------\n"
            ."Name: ".$name."\n"
            ."E-mail: ".$email."\n\n--------PHONE--------\n"
            ."Phone: ".$phone."\n"
            ."Location: ".$location."\n"
            ."Best time to contact? ".$best_time."\n"
            ."Inquiring About: ".$details."\n";
//----------------------------------
mail($email, $subject, $receiptMessage,"From:$toAddress");
//----------------------------------
mail($toAddress,$recipientSubject,$mailContent,"From:$email");

This line:

$toAddress="" . $row['email'] . ""; /* change this! */
?>


is populated by a query/array. This represents the email address of the person/member the visitor wants to contact. The email confirmation the visitor receives shows the proper 'from' email address so I know it's populating that correctly.

Why it sends one and not the other is the mystery. Anyone?

#2 HuggieBear

HuggieBear
  • Members
  • PipPipPip
  • Advanced Member
  • 1,899 posts
  • LocationEngland, UK

Posted 19 October 2006 - 08:42 AM

This line:

$toAddress="" . $row['email'] . ""; /* change this! */

is populated by a query/array. This represents the email address of the person/member the visitor wants to contact. The email confirmation the visitor receives shows the proper 'from' email address so I know it's populating that correctly.

Why it sends one and not the other is the mystery. Anyone?


As you're not specifying $row['email'] anywhere, I'm assuming this is only part of your code, is this whole block inside a while loop?

Regards
Huggie
Advice to MySQL users: Get phpMyAdmin and test your queries work there first, take half the hassle out of diagnosis, also check the reserved words list.

Links: PHP Docs :: RegEx's :: MySQL :: DevGuru :: w3schools

#3 simcoweb

simcoweb
  • Members
  • PipPipPip
  • Advanced Member
  • 1,102 posts
  • LocationCA

Posted 19 October 2006 - 01:58 PM

Basically $row is established as part of a query. Here's the code:

<?php
// need to get member data
$sql2 = "SELECT * FROM plateau_pros WHERE memberid = '$memberid'";
$results = mysql_query($sql2);
$row = mysql_fetch_array($results);
?>

This query's results then are sprinkled throughout the page like this:

<?php
echo "<h2>Inquiry Sent!</h2><br><font class='bodytext'>Thank you for your contact submission! <b>" . $row['firstname'] . " " . $row['lastname'] ."</b> will respond to your inquiry as soon as possible. We also encourage you to contact <b>" . $row['firstname'] . " " . $row['lastname'] ."</b> directly by email or phone:<p>
<ul>
<li><a class='body' href='mailto:" . $row['email'] . "'>Click here to email</a></li>
<li>Phone: " . $row['phone'] . "</li>
<li>Mobile: " . $row['mobile'] . "</li>
</ul><br>\n";
exit;
?>

As well as in that snippet your quoted where i've inserted the $row['email'] in order to have the email sent to the member chosen.

The script is a contact form whereas the visitor first chooses a member they wish to contact. When they select that member the memberid is passed via the URL and snagged with a $_GET. Then the query is run based upon the $_GET['memberid'], extract that member's data and displays it where needed. That query code is right above the form mail code. But, there's no 'while' loop.

The form is successfully emailing this one to the visitor:

mail($email, $subject, $receiptMessage,"From:$toAddress");


but not this one to the member:

mail($toAddress,$recipientSubject,$mailContent,"From:$email");


The one that does get sent to the visitor shows the proper return address which would be the member's email as placed by " . $row['email'] . "

#4 HuggieBear

HuggieBear
  • Members
  • PipPipPip
  • Advanced Member
  • 1,899 posts
  • LocationEngland, UK

Posted 19 October 2006 - 02:17 PM

ok, can you try something to humour me then... Can you change your database so that both the email addresses are the same, make the sending member's email address and the receiving member's email address the same as the one that successfully received the email, then see if they both turn up.

This way, you'll know if it's the code or a mail delivery issue.

Regards
Huggie
Advice to MySQL users: Get phpMyAdmin and test your queries work there first, take half the hassle out of diagnosis, also check the reserved words list.

Links: PHP Docs :: RegEx's :: MySQL :: DevGuru :: w3schools

#5 simcoweb

simcoweb
  • Members
  • PipPipPip
  • Advanced Member
  • 1,102 posts
  • LocationCA

Posted 19 October 2006 - 02:34 PM

Ok, I chose a member id that has my email address in it and then used the same email address as the visitor. So, I should've received both emails. Neither one showed up.

When I used my hotmail account as the visitor then it would show up in my hotmail account and the 'from' address would be the email address of the member which is the same one I just tried. It's a valid email address and I triple checked it.

So, we know it will send to my hotmail account so it's not entirely a delivery problem. However, it wouldn't send to my domain account which is hosted on the server this script is running on.

Ideas?

#6 HuggieBear

HuggieBear
  • Members
  • PipPipPip
  • Advanced Member
  • 1,899 posts
  • LocationEngland, UK

Posted 19 October 2006 - 02:38 PM

OK, so if you received it in your hotmail account, change both email addresses to your Hotmail account and see if both emails turn up.

Regards
Huggie
Advice to MySQL users: Get phpMyAdmin and test your queries work there first, take half the hassle out of diagnosis, also check the reserved words list.

Links: PHP Docs :: RegEx's :: MySQL :: DevGuru :: w3schools

#7 simcoweb

simcoweb
  • Members
  • PipPipPip
  • Advanced Member
  • 1,102 posts
  • LocationCA

Posted 19 October 2006 - 02:55 PM

Interesting...... both showed up in the Hotmail account.

#8 HuggieBear

HuggieBear
  • Members
  • PipPipPip
  • Advanced Member
  • 1,899 posts
  • LocationEngland, UK

Posted 19 October 2006 - 03:00 PM

In that case it is a delivery issue, and the problem's with your host, not your script.

Regards
Huggie
Advice to MySQL users: Get phpMyAdmin and test your queries work there first, take half the hassle out of diagnosis, also check the reserved words list.

Links: PHP Docs :: RegEx's :: MySQL :: DevGuru :: w3schools

#9 simcoweb

simcoweb
  • Members
  • PipPipPip
  • Advanced Member
  • 1,102 posts
  • LocationCA

Posted 19 October 2006 - 03:35 PM

heh...i'm not sure if i'm happy or sad. It's my server  :'(  But at least I know the code is good!  ;D

Thanks for helping.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users