October 13th, 2000, 06:54 PM
I have a dedicated linux web server and I am trying to use the PHP mail()
function to send emails any site visitor that requests one. This works only if the visitor has an email account on the
box. If not then the email request fails. I
think this must be something to do with relaying and I have been entering
domains and hosts (such as "localhost") to get the script to trust the source of the email request and relay it. Unfortunately I have not had any success. Can you help?
October 13th, 2000, 09:08 PM
Well, all I can say is that I have my copy of PHP setup local.. running on win9x Xitami PHP4.0.2
I execute the mail function all the time, and the mail goes..
I did have a couple of rejected messages the other day, both from hotmail.. seems hotmail didn't like where the message came from.
my PHP.ini file is set up to send mail to via my SMTP server.. in my case
it's my hosted domain name..
But I see no reason why (and I could be wrong) PHP could not send mail via an ISP's mail server..
Low Cost Hosting and Web Development.
October 15th, 2000, 05:14 PM
Thank you for your advice and it is good to know that it is likely that I can succeed when I work out which configuration to change. I know I must be able to do it because the PHP Mail() script works on my hosted web space provided by my ISP, even from an anonymous dial-up connection. It's just trying to do it on my Linux web server that is giving me a challenge.
The mail() function is very basic and there seems to be no way of running it as a named user so I shall have to try and work out how to get either PHP, Linux or Sendmail to trust the source of the script.
I have configured a variety of hosts and IP addresses to convince my server to trust the source of my mail() script but to no avail. I have used localhost, 127.0.0.1 and even httpd. The mail() function works when I am sending to mailboxes on the same server as is running the script, and these messages are sent from firstname.lastname@example.org. This domain is odd because it is the name server, the actual domain is vivendiwatersystems.co.uk.
I think that I need to learn a bit more about the configuration options and particularly sendmail as I think the problem may be here.
I have also checked the php3.ini file but two of the three sendmail options apply to Windows servers and the remaining one is just a path statement, so I am not too sure what to do here. I feel I am in danger of playing with various configuration options without really understanding what I am doing and causing all sorts of consequential problems.
However, any more thoughts would be appreciated.
October 20th, 2000, 04:19 AM
On a slight tangent, if a visitor mistyped their email address, do you receive the bounced email?
It's a problem I'm struggling with. (We can discuss off-line if you'd prefer)
October 24th, 2000, 06:18 PM
Unfortunately, I am not sure your issue is related. I would have thought the any miss-spelt email address would have logged as a failed email in either you email software, and/or Sendmail. Assuming you are using Linux, then when you log in to your shell it should tell you that you have mail. Viewing this mail should give you a clue as to where all stray mail is going.
Fortunately, however, I have now solved the problem, in fact the problem was nothing to do with PHP but was caused by the Internet being unable to resolve the default domain name which Sendmail used sending mail generated by the PHP function.
Sendmail uses the host name of the web server as the sending domain for mail generated by PHP's mail() function. The problem was that the host name of my box was set to be my name server, and not the domain itself. My name server address should have worked, of course, except that my domain name was resolved by the name servers of the company that sold me the domain name - not my own. Therefore, when the server receiving mail performed a reverse look-up the mail delivery failed because it could not recognise the sender. However, when I sent mail to another domain on my web server the name resolved OK because it did not need to go out to the Internet.
My problem was solved by my domain supplier registering my domain name servers, and not theirs, with the UK's domain registration authority. This meant that the Internet could resolve ns.vivendiwatersystems.co.uk and all is well. For now!!