Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

PHP Mail not working where MX hosted by different server? 1

Status
Not open for further replies.

ulteriormotif

Technical User
May 18, 2003
79
0
0
NZ
I have a website hosted on "SiteHost1", but the email is handled by "MailHost2" through an MX redirect.
General email is working fine and dandy.

The problem is that the PHP Mail script that I use to send emails to new users I have registered on the site is no longer working. In short emails are not arriving to the address they are sent to, but no errors are generated - the new member is being inserted into the database, and I am getting my on-screen confirmation that the email has been sent (see end of posted code), but it never arrives.

It worked fine prior to the MX redirect being put in place, and the identical code continues to work fine on another site I have where sitehost and mailhost are one and the same.

I am assuming therefore that it's likely something to do with the email being hosted remotely?

The following is the portion of my php code that sends the email, though as stated this has been working fine until now.

----------------------------------------------------------
(get the info and insert in the database after error checking, etc, then send the following email

$userid = mysql_insert_id();
$subject = "Your membership at example.com";
$myname = "Mysite Webmaster";
$message = "<html>
<head>

</head>

<body>Dear $first_name $last_name, <p>

A user account has been created in your name at example.com.<p>

You are two steps away from logging in and accessing our exclusive members area.<p>

To activate your membership, please click <b><a href=\"
Once you activate your membership, you will be able to log in with the following information:<p>

Username: $newusername<br>
Password: $random_password<p>

Thanks!<br>
Webmaster<p>

This is an automated response. Please do not reply </body></html>";

mail($email_address, $subject, $message,
"MIME-Version: 1.0\r\nContent-type: text/html; charset=iso-8859-1\r\nFrom: $myname<webmaster@example.com>n
X-Mailer: PHP/" . phpversion());

echo 'Membership information has been mailed to the new user\'s email address. User should check their email and follow the directions!<p><a href=adm_newuser.php>Register another new user</a>';
---------------------------------------------------------

help?
 
Your code returns no errors because everything works okay. All mail() usually does is hand the message off to a local mail server. All the return of the mail() function can tell you is whether this handoff happened correctly.

Check the queue and logs on the local mail server. The reason for your mail's not getting through is likely there.



Want the best answers? Ask the best questions! TANSTAAFL!
 
Thanks sleipnir214. I thought that might be the case.

Along that localhost line, I have some further progress:

Occurred to me that the new test members I had been trying to set up were using addresses at another of my sites, hosted on the same server as example.com.

So have tried setting up a member with a completely unrelated email address and the email has gone through fine.

Also tried setting up a member using an example.com email address, and this has also gone through fine.

It appears the problem is setting up members on other domains hosted on the same machine.

Any thoughts?


 
Cool, thanks sleipnir - I've got a support ticket in with my host to see if they can shed any light. Fingers crossed.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top