#1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2000
    Posts
    0
    Rep Power
    0
    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?
  2. #2
  3. No Profile Picture
    Robert_J_Sherman
    Guest
    Devshed Newbie (0 - 499 posts)
    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..

    ------------------
    SnR Graphics,
    Low Cost Hosting and Web Development.
  4. #3
  5. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2000
    Posts
    0
    Rep Power
    0
    Robert,

    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 httpd@ns.vivendiwatersystems.co.uk. 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.

    Regards
    Keith Attfield
  6. #4
  7. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2000
    Location
    London, UK
    Posts
    14
    Rep Power
    0
    Hi Keith

    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)

    Cheers
    Mark
  8. #5
  9. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2000
    Posts
    0
    Rep Power
    0
    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!!

Similar Threads

  1. How do I set up mail?
    By ITmax in forum Mail Server Help
    Replies: 4
    Last Post: June 1st, 2005, 09:56 AM
  2. Send mail only works for some addresses
    By jmiles in forum PHP Development
    Replies: 3
    Last Post: March 3rd, 2004, 04:12 PM
  3. How can i set a Priority mail?
    By Jollyguy in forum PHP Development
    Replies: 0
    Last Post: February 8th, 2004, 11:24 PM
  4. Help with script
    By akastarlight in forum Perl Programming
    Replies: 1
    Last Post: February 6th, 2004, 06:55 AM
  5. mail() not working with ISP's mail server
    By wjones8050 in forum PHP Development
    Replies: 2
    Last Post: January 9th, 2004, 02:47 PM

IMN logo majestic logo threadwatch logo seochat tools logo