-
stanger: Neither of those would work, unless you changed the $postmastermail variable to be an command line argument to, for example, sendmail.
If the same email is always going to be used as the From: address, it'd be better to define it as a constant in a globally-included PHP file, e.g.:
define('POSTMASTER_EMAIL', '[email protected]');
define('POSTMASTER_NAME', 'Negative');
then you'd have:
$mailHeaders = 'From: ' . POSTMASTER_NAME . ' <' . POSTMASTER_EMAIL . '>' . "\n";
I use a similar method on my sites (except I pass the constants as an argument to a method of my mail class, rather than editing the headers manually in each script) and it makes life a *lot* easier.
Quote:
Originally posted here by Negative
Mr. Waring, you are a genius... or I'm an airhead, whichever works...
Neither - I'm no genius with PHP and it was an easy mistake to make - I've made a similar one in the past and it took me ages to track it down. There's no better teacher than experience! ;)
-
Neg, I had problems with the mail function aswell.
For some reason '\n' wasn't working to end header, to, subject, message fields and I was getting weird error messages, so after a little research I found that as a hold-over from ancient times '\r\n' is more acceptable.
But, I am by no means submitting that I actually understand or am correct in this, I just know that I was trying everything, but as I am not a scientist I think my last attempt combined two changes and it worked thereafter, so I don't know if it was the first or the second change.
My problem was a different, I had a form to contact one out of a set of administrative users, but didn't want to put mailto: links, so I've got a select drop-down menu that keeps UIDs and then queries the DB to get the addy and then send.
Peace,
Dhej
-
I use "\r\n" in my scripts (and you have to use double quotes or else it won't be interpolated) and it seems to work. I don't know if there is a difference between the two (I know there is when dealing with ASCII files - \n is the line ending on Unix, \r on Mac and \r\n on Windows) for mail but I've always used \r\n and it's always worked.
Dhej: That drop-down menu idea is a good one, I especially like the concept of keeping the email addresses in a database because that way they can't be harvested by spam bots (because the addresses won't even be in the HTML source code output to the browser). I've never had anyone other than me working on my sites, so I've never needed more than one email (which is why I used define() rather than a database query) but it's a good idea nonetheless.
-
ahh cool, so I'm not completely wrong with the "\r\n", and I looked at my script and in my headers I've used \n between things like X-Mailer: and such, but ended the section with /r/n
I can't take credit for the drop down, that was acually suggested to me by my "client" (my friend that I am making the site for)., but it sure made things easier for a lot of things, I've got the script so that it won't let the same IP send to the same email addy more than twice in 50 min, it logs all vitals to database, and should mail() return false it save the message body in the DB aswell, which has actually save my butt a couple of times. (Like when I accidentally botched the script with a minor modification to the headers... I've got it set up so that it will catch the UID through $_GET aswell, so that I can have anyplace that a username pops up have a link to contact.
There is only 4 usernames on the site, which filter into 2 people, which makes it condusive to the select menu, too many more and it would be too long I think.
Cheers,
Dhej