Jump to content

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


Recommended Posts

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:

[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");[/code]

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

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?
[quote author=simcoweb link=topic=111936.msg453942#msg453942 date=1161199221]
This line:
[code=php:0]$toAddress="" . $row['email'] . ""; /* change this! */
[/code]

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?
[/quote]

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
Basically $row is established as part of a query. Here's the code:

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

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

[code]<?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;
?>[/code]

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:

[quote]mail($email, $subject, $receiptMessage,"From:$toAddress");[/quote]

but not this one to the member:

[quote]mail($toAddress,$recipientSubject,$mailContent,"From:$email");[/quote]

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'] . "
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
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?
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.