PHP and mail( )

Robizzle01

Limp Gawd
Joined
Sep 30, 2005
Messages
159
Some of you may remember that i'm setting up a book trading website for my university. I decided to start out slow and build up to harder tasks since i've never delt with mysql and only limited php before this. I think i'm holding my own with the database and php but i'm having problems getting msu.edu to accept emails generated from my server -- they dont even make it into the spam foler :(

Wrote a very simple mail test and found that my computer is sending the emails but msu chooses not to accept them. mail() returns true tho, so as far as apache knows, the mail was sent. I tried sending to my gmail account instead, and the emails worked just fine. Below is the script i'm using.

Code:
<?php

$to	= "meyerro3@msu.edu";
$to2	= "Rob.Meyer1@gmail.com";
$subject= 'the subject';
$message= 'this is the body of the email';
$headers= 'From: [email]webmaster@robmeyer.net[/email]'."\r\n".'Reply-To: [email]webmaster@robmeyer.net[/email]'."\r\n".'X-Mailer: PHP/'.phpversion();

if(mail($to, $subject, $message, $headers))
	echo "Mail sent to ".$to;
else
	echo "Mail to ".$to." failed";

if(mail($to2, $subject, $message, $headers))
	echo "Mail sent to ".$to2;
else
	echo "Mail to ".$to2." failed";

?>

So i'm wondering where the problem lies. Is it something wrong with my headers, is it that msu.edu simply doesn't like my server's IP address (afterall it is just a desktop sitting on the floor next to me in my apartment.) Or is it something to do with my settings in godaddy?

I'm more than willing to supply you guys with any further information that you need, but I simply dont know what you may need to know at this point. I've never played with sendmail before (i'm using postfix if that makes any difference) and I dont really know anything about A and MX records.

I did run the dnsreport on robmeyer.net and it passed everything except for "Acceptance of postmaster address. ERROR: One ore more of your mailservers does not accept mail to postmaster@robmeyer.net. Mailservers are required to accept mail to postmaster." The gentoo guide I was following said it would come back to that later but then I got stuck http://gentoo-wiki.com/HOWTO_Email:_A_Complete_Virtual_System_-_Postfix_to_Postgres. I couldn't run the last line as I dont have telnet and emerge telnet didn't find any such package.

If it turns out that there is no way to get msu.edu to accept mails from my desktop, then I guess that is how it will have to be. But what are the chances that it will work when I decide to rent webhosting? I'm still trying to decide between ashosted.com and made2own.com but if email from them isn't going to work, then I dont know what i'll do about this. I need to validate my user's email addresses somehow.

Thanks for help in advance, you all rock.
 
I sortof ran into a problem with yahoo not accepting my emails from my domain. What happened was my domain has been blacklisted in a few lists due to the fact that my secondary MX record points back to my residential IP...so a reverse lookup on my domain for that server would instead reveal it as a comcast first...not my domain...so it fails and my emails to yahoo get filtered off to the 'junk' folder.


http://www.mxtoolbox.com/blacklists.aspx
 
I ran into the same problem, being blacklisted, when trying to send messages to my .edu account. Usually residential IPs are grouped together and that whole group is blacklisted, there's a list that keeps track of just residential IPs. I ended up relaying my server to send mail through my ISP (Comcast).
 
So this shouldn't be an issue if I get hosting from, for example, ashosted or made2own? This is only a problem with the fact that my computer is on a residential IP address and this particular mail server has it on a blacklist? So, I shouldn't even bother with trying to change my godaddy DNS settings since as long as my computer is in my apartment it wont work?
 
After looking more closely it looks like it may be that msu.edu is rejecting the email because the reverse DNS fails. How do I go about setting this up? Is it something in my MX records or is this a server-side configuration change? Not even sure what a reverse DNS is.

DNS Report for robmeyer.net

Code:
FAIL	Reverse DNS entries for MX records	ERROR: The IP of one or more of your mail server(s) have no reverse DNS (PTR) entries (if you see "Timeout" below, it may mean that your DNS servers did not respond fast enough). RFC1912 2.1 says you should have a reverse DNS for all your mail servers. It is strongly urged that you have them, as many mailservers will not accept mail from mailservers with no reverse DNS entry. You can double-check using the 'Reverse DNS Lookup' tool at the DNSstuff site (it contacts your servers in real time; the reverse DNS lookups in the DNS report use our local caching DNS server). The problem MX records are:
94.135.176.69.in-addr.arpa [No reverse DNS entry; 'Server Failure' (check it)]

FAIL	Connect to mail servers	ERROR: I could not complete a connection to any of your mailservers!

robmeyer.net: Timed out [Last data sent: [Did not connect]]

If this is a timeout problem, note that the DNS report only waits about 40 seconds for responses, so your mail may work fine in this case but you will need to use testing tools specifically designed for such situations.
 
yeah, i'm not.

Blacklist Test, enter 69.174.135.94 or use the mx lookup on "robmeyer.net" then click the blacklist button.

There are a bunch of timeouts at the bottom but those even happen when I checked comcast.net. And i know msu.edu isn't blocking them...
 
Doesyour mail error log on your server show why the other server is rejecting the messages? That's how I found out mine was blacklisted, my university was sending back a link to the list provider.
 
Many mail servers these days check reverse dns information. In order to get the message out you need a dns server for the domain you're sending from and that domain needs to have valid reverse entries. If you don't have one set up you should try to change your mail server on your php box to route mail to another valid server that can send on your behalf.

Is this Michigan State? I work with them on some things and know recently they've been upgrading their mail infrustructure.
 
Yes, it is Michigan State. As for the reverse dns, i'm using godaddy dns to point robmeyer.net to 69.176.135.94 which is my test server. I got hosting from ashosted ( http://www.usedtastic.com ) and emails generated from that server are getting into my msu mailbox just fine. When I started this thread I didn't have any hosting and I was trying to get my test server working fully. It still isn't getting into msu but i'm almost certain reverse dns is to blame. I just have no idea how to set it up...

godaddy_settings.png


Those are my current settings that work fine with gmail but msu is blocking the mail (not spam folder but straight ignoring.)
 
The problem would indeed by the lack of the PTR record for Reverse DNS. You need to contact whomever you are getting your internet connectivity from (Spartan Net? That's what the IP WHOIS says) and have them setup a PTR record for you. Once you've done that, if you are still having problems, send a test message from that server to somewhere that can read it, and post the headers of the message
 
Back
Top