php can't send mail

Posted:
in Genius Bar edited January 2014
for some reason, php scripts that send mail, can only send it to ME, and no one else. I host my own mail, using the SMTP server IN OS X Server. So everything is on the same machine, so php can send mail to my machine, but no further. I can send mail, using Mail.app, no problem. I know php can use sendmail, but I'd rather just set it up simply to use SMTP, I know sendmail can be a real pain to set up.

Comments

  • Reply 1 of 14
    thuh freakthuh freak Posts: 2,664member
    how are you dealing with mail in php? are you opening up a pipe into a mail server and handling the protocol yourself? or are you passing onto a separate program? or are you using some api?



    also, in mail.app, what do you have as your outgoing smtp server? (is it ur localhost?) and are you connecting to the same outgoing smtp server in php? also, what do you use as your mailserver? (if not sendmail: the osx default, then postfix?) is it setup as a relay station to pass messages on to other final destinations?
  • Reply 2 of 14
    l008coml008com Posts: 163member
    Quote:

    Originally posted by thuh Freak

    how are you dealing with mail in php? are you opening up a pipe into a mail server and handling the protocol yourself? or are you passing onto a separate program? or are you using some api?



    also, in mail.app, what do you have as your outgoing smtp server? (is it ur localhost?) and are you connecting to the same outgoing smtp server in php? also, what do you use as your mailserver? (if not sendmail: the osx default, then postfix?) is it setup as a relay station to pass messages on to other final destinations?




    I use the SMTP server that comes with OS X Server. Mail.app uses that for incoming and outgoing. It can relay mail but only mail that comes from its own IP, or a few certain other IPs. How php sends mail, I don't know, all my phps are downloaded.
  • Reply 3 of 14
    thuh freakthuh freak Posts: 2,664member
    ok, can you look through your php's to see how they are trying to send mail? or post them somewhere that i can view them to track down the problem.



    in the mean time, try this (on the command-line):

    Quote:

    telnet 127.0.0.1 25;

    HELO me

    MAIL FROM: [insert your login name without spaces or braces]

    RCPT TO: [insert a separate email address you have on some other email server, like a yahoo or .mac, again without spaces or braces]

    DATA

    this is a test message

    .

    QUIT



    (note the period on a separate line after the "...test message"; its needed.)



    then wait up to 20 minutes and check the address from the "RCPT TO:" line. what that stuff does is connect to your local smtp server, and sends an email from [your log name] to the [separate email address]. its a test to see if your local smtp server will relay messages past your machine. if that works, then we know that php isn't properly sending mail; if it doesn't work then your mail server needs to be configured as a relay station.



    edit: chg'd the code-block into a quote, cuz the formatting was really fukked up.
  • Reply 4 of 14
    l008coml008com Posts: 163member
    ok thats very strange, i tried that, and it wouldn't let me relay the mail, it said no SMTP relay allowed from this host, but this is the same host i run mail on, and i can send mail all day long with it no problem. Thats very strange, i don't understand. Also I have my mail server set up to allow mail relay from 192.168.*.* which should cover my entire LAN.
  • Reply 5 of 14
    l008coml008com Posts: 163member
    Also the PHPs i have that send email are big multi file php programs, and i really can't read php very well, and i couldn't really find the sections where mails are actually sent.
  • Reply 6 of 14
    l008coml008com Posts: 163member
    I also just tired that telnet thing from my server itself, and it also would not let me send email. Very strange, it would definatly seem that the problem is my mail setup, i just can't figure out why it works fine for Mail.app but won't work at all from the terminal.
  • Reply 7 of 14
    thuh freakthuh freak Posts: 2,664member
    well, in mail.app, you setup email accounts and per account you can setup an incoming and an outgoing mail server. i think you can also have a backup outgoing server if the per account version doesn't work. i suspect that if you check it out you'll have a different outgoing mail server than you might have thought (maybe something external, or somewhere that allows relaying). you may want to try to setup php to use some external mail server, like mail.yahoo.com (i think they allows outside email to go through). also, i recommend that you download and install postfix. its a more secure mail server, and it boasts compatibility with sendmail. i'm pretty sure that it, by default, enables mail relay, if not, its fairly simple to edit its configuration. i'm not very familiar with sendmail, but there is probably a way to make that relay mail as well.
  • Reply 8 of 14
    l008coml008com Posts: 163member
    No I'm very sure that all my mail accounts in Mail.app use my own mail server for both incoming and outgoing mail. Which makes it very strange.
  • Reply 9 of 14
    torifiletorifile Posts: 4,024member
    I'm a little confused about what mail.app has to do with your php sending mail. Sendmail and mail.app are two completely different things. Have you set up an MX record with your DNS host? (Maybe I'm misreading, but to send mail out to the world, I believe you need to do this.)
  • Reply 10 of 14
    thuh freakthuh freak Posts: 2,664member
    Quote:

    Originally posted by torifile

    I'm a little confused about what mail.app has to do with your php sending mail. Sendmail and mail.app are two completely different things. Have you set up an MX record with your DNS host? (Maybe I'm misreading, but to send mail out to the world, I believe you need to do this.)



    well, as i read it, he can send outgoing mail through his mail server in mail.app, but he can't send outgoing mail through his mail server in php pages. also, i dont think one necessarily has to route mail through their dns host. if sendmail is configured correctly, one can send mail through any mail server (or atleast thats what i think).



    i think at this point, you should go to the php. ask whoever wrote it to point you in the write direction, or try grep'ing through the pages to find 'mail' or 'sendmail'.
  • Reply 11 of 14
    l008coml008com Posts: 163member
    Freaks right on track, and yes MX records are A-OK
  • Reply 12 of 14
    gargoylegargoyle Posts: 660member
    have you checked your php.ini file the correct settings ?
  • Reply 13 of 14
    l008coml008com Posts: 163member
    Quote:

    Originally posted by Gargoyle

    have you checked your php.ini file the correct settings ?



    No i was very confused just where exactly that files goes on OS X and what is supposed to go in it.
  • Reply 14 of 14
    torifiletorifile Posts: 4,024member
    Quote:

    Originally posted by l008com

    No i was very confused just where exactly that files goes on OS X and what is supposed to go in it.



    Code:




    <?

    phpinfo();

    ?>









    put this script in a file (call it test.php or something) in your webserver folder (/Library/WebServer/Documents, if you haven't changed anything). Go to http://127.0.0.1/test.php . That'll give you a lot of info about your php setup. Then we'll get some needed information.



    edit: make sure you delete the file when you're done. It may give info to hackers, so you don't want it lying around too long.
Sign In or Register to comment.