PHP mail not working?

software development

#1

I had it running for the past year in my PHP script and suddenly it is not working. Any idea?


#2

“I had it running for the past year in my PHP script and suddenly it is not working. Any idea?” … not without seeing at least the relevant part(s) of your script!

–rlparker


#3

Oh sorry,

It is an online feedback/ordering forms. Contents will channelled to my email directly…and it is using PHP mail command…

something like this and was running fine for past year. I didnt change anything


$customerinfo .= “

OrderID=”.$orderid."

";
$customerinfo .= “”;
$content = $confirmation . $content.$customerinfo;

$header = "From:XXX@gmail.com\r\nbcc:XXX@gmail.com\r\n";
$header .= “MIME-Version: 1.0\r\n”;
$header .= “Content-type : text/html;”;
//$header .= " charset=iso-8859-1\r\n";
$header .= " charset=UTF-8\r\n";

mail($email, $subject, $content, $header);

thks


#4

No prob…

At first glance, I don’t see anything obviously wrong with your code, though I cant tell from your snippet how you have assigned the value of $email, $subject, or $content.

When you say it’s “not working”, what are you seeing happening? Are there any error messages? Any bounces or anything that indicates anything at all has happened? Does the mail() function return value of “true” or “false”?

I’m thinking the value returned by mail() is your first step, as it will tell you whether or not the mail was successfully accepted for delivery.

Also, depending upon what you mean by “not working”, the mail might just be delayed for some server/queue related reason (which might make sense as the code “worked” before) - that’s why I suggest determining value the mail functions returns. From the PHP manual:

[quote]Return Values

Returns TRUE if the mail was successfully accepted for delivery, FALSE otherwise.

It is important to note that just because the mail was accepted for delivery, it does NOT mean the mail will actually reach the intended destination. [/quote]
If the mail was accepted for delivery, that helps in trying to figure out what else might be happening.

–rlparker


#5

Hi,
I don’t see any error messages on the screen. Everything seems to be normal except I don’t receive the mails as I expected to. I dont expect the script to be wrong as it has been running for almost a year. I used the PHP mail command in 3 different pages. All failed to work from the same day…

I just created a simple script:

<?php $content ='testing 123'; $subject = 'This is a subject'; $email = 'wongingong@yahoo.com.sg'; $header = "From:wong.ing.ong@kbr.com"; echo mail($email, $subject, $content, $header); ?>

It is working fine on my other domain where I can receive mail but not on dreamhost…It seems like something being modified at a higher level…

The above return 1 on the screen.,


#6

Well that seems to narrow things down a bit, as the “test” mail you included went out ok it pretty much eliminates any kind of general DH block on the mail sending from the script (which can happen if you exceed outgoing mail quotas, or got beefed for spam, or such).

I would also check the actual code involved with a “echo” from the mail function to see if I also get the “1” (TRUE) return there.

Other than that, I don’t know what else to suggest except contacting support; the fact it quit working after it initially worked for a long time it hard to explain unless something changed at Dreamhost. I’m sorry, but I just don;t have any other ideas :frowning: Good Luck with it, and let us know what you find out if you write support!

–rlparker


#7

hi,
already contacted support 2 days ago… they claimed that it is working fine… fact is: it is not…

thanks for help…


#8

I’m sorry they couldn’t provide more help…the only other thing I can think of is that the emails might have gotten swallowed up by spam filter at the receiving end…but I don’t doubt you have already checked out that possibility :frowning:

–rlparker


#9

yes, checked that, used different email addresses too…no luck…


#10

The script and the domain that’s using it are both hosted here, right? If not, it’s probably blocked.

I’d do the simple mail() test from a domain that’s hosted here, using one of your Dreamhost emails, rather than Yahoo, etc. Since DH won’t block their own servers, it will eliminate all outside problems.

mail(‘you @ a DH address’, ‘test subject’, ‘test message’);

Also, you might want to post what server you’re on and maybe someone else that’s on it can confirm that the function is working fine.


:stuck_out_tongue: Save up to $96 at Dreamhost with ALMOST97 promo code (I get $1).
Or save $97 with THEFULL97.


#11

Sadly, still no answer…

Yes, script and domain are at DM. Running well for past months without problem…

If DM can only DM mails, then it must be something new that I am not aware of…

I dont know what to do now other than asking support people to run their own script at my domain and prove to me that it is indeed working…


#12

Did you run that example I gave you? Just a simple mail() with your DH hosted email address, subject & message – no extra code or headers.

If that works, mail() is working. You can definitely email outside of DH, but that would show that it’s a filtering problem on the receiving end for your yahoo account… since DH isn’t going to block their own servers.


:stuck_out_tongue: Save up to $96 at Dreamhost with ALMOST97 promo code (I get $1).
Or save $97 with THEFULL97.


#13

So your simple test script didn’t work, either? I wonder if the return-path and reply-to headers aren’t being set correctly by DH. I’ve not used mail on DH servers before, so I don’t know if they’ve set it up correctly.

One thing to try in your test script (that may or may not work) is set in the headers Reply-to: and Return-path:
Set the To, reply to, and return path to the same address, such as a gmail account of yours. Run the script, then look in your inbox as well as your spam box. If you get the message, look at the full headers of the message and see if reply-to and return-path are set correctly. At the very least, it’ll assure you that mail is formatted correctly.

Possibly the mail is getting flagged as spam because php is sending out mail with reply to/return path as “php@localhost” or something like that. Depending on where the mail is going, the mail could be flagged as spam. Basically, you need to be able to see the headers of the mail that are sent out.

(Are you using a custom PHP install with your own php.ini? If so, you can set those two fieldsd in the ini file.)


Jonathan


#14

It is working now :slight_smile: after 6 long days :frowning:

DM’s support told me they restarted the postfix(outgoing mailserver). All the old mails stuck at the server started showing up…

Am I the only one having this problem? Took quite a while to resolve this, isn;t it?

Thanks for the help…


#15

Well, It’s a good thing they finally got it restarted, but not real encouraging that it took six days to get to the bottom of it. :frowning:

I noticed in an earlier thread re. mailman list software that something similar had happened to another user and I’m hoping DH develops a better way of monitoring such situations. 6 days of testing, aggravation, and worry only to have the situation resolved by restarting a mailserver does not leave me with “warm fuzzy feelings” :wink:

It’s particularly irritating as there really isn’t anything we can do about fixing it from our end - we just have to wait till they figure it out…arguugh!

–rlparker