Announcement

Collapse
No announcement yet.

PHP's mail() function

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • PHP's mail() function

    Whenever I use the mail() function to send e-mail, it shows the sender as:

    Nobody <[email protected]> on behalf of John Miller <[email protected]>

    That's using a From: header.

    Code:
    	$from = "John Miller <[email protected]>";
    	mail($email,$subject,$message,"From: $from\n");
    This is for a mailing list program so I can't have it being sent as nobody!

  • #2
    I believe PHP sends all mail as if it were a user named PHP - I don't have time to confirm this or go into details, but I believe that's what your problem is.

    -jim
    "The dot-com bust has cleared out the carpetbaggers and left the Internet to those who really care about it"
    - Jon Ippolito, new-media curator, Guggenheim Museum

    Comment


    • #3
      I know what the problem is but how do I fix it?

      Comment


      • #4
        You write to this guy named Rasmus Lerdorf, and ask him to change how his programming language runs under Apache.

        -jim
        "The dot-com bust has cleared out the carpetbaggers and left the Internet to those who really care about it"
        - Jon Ippolito, new-media curator, Guggenheim Museum

        Comment


        • #5
          Jim that can't be right, mail sent throug vbulletin appears as it is sent by me with my name (when i send a mailing list)

          try this:

          Code:
          "From: [email protected]\r\nReply-to:[email protected]"

          and see if that works.
          Christopher Padfield
          Web Based Helpdesk
          DeskPRO v3.0.3 Released - Download Demo Now!

          Comment


          • #6
            I think when you are running PHP as an Apache mod it shows up as nobody due to the PHP being considered user "nobody" by the server while it is running.

            When running PHP as CGI, the user shows up correctly due to how it runs.

            This would account for some people having different results, depending on their particular server config. I can't help as far as a solution though...I have not yet studied or used any of PHP's mail functions.


            Ben


            Comment


            • #7
              really.. so any big company that uses PHP to send mailing lists must have PHP run as a cgi.

              JohnM, when you send a newsletter through vbulletin does it come out as sent from user nobody as well?
              Christopher Padfield
              Web Based Helpdesk
              DeskPRO v3.0.3 Released - Download Demo Now!

              Comment


              • #8
                Here is some info I just ran across...I haven't had a chance to check the supplied link, but it's better information that I could give


                [email protected]
                12-Apr-2000 10:28

                After much research, and more than a little time spent, I have found an answer to the "problem" of headers in received mail like From:[email protected]

                RFC822 makes it plain that the header "Return-path" is intended to be added to the message by the mail program at the destination(POP3), not at the source(SMTP). Adding it as a header to a mail() function will have no effect as mail() is the source.

                If you have PHP compiled into Apache, then PHP mail() sends email to sendmail as the owner of the process which, of course, is 'nobody'. So sendmail will use 'nobody' in the "From" field of the sendmail generated portion of the header.
                The solution is to follow the instructions in the sendmail configuation to reverse-map outgoing mail to "[email protected]". Here is the URL to those instructions: http://www.sendmail.org/virtual-hosting.html
                Follow instructions 6 and 7 and you will have no further problems.

                Comment


                • #9
                  Only problem is I'm on a shared server, can't edit any config files or php.ini.

                  Comment


                  • #10
                    Originally posted by chrispadfield
                    JohnM, when you send a newsletter through vbulletin does it come out as sent from user nobody as well?
                    Yup, different server too.

                    Comment


                    • #11
                      I believe that quote is incorrect
                      Return Path works for me with mail()
                      I have php compiled into apache.

                      Comment


                      • #12
                        found this:

                        To all the people who are wondering why their email's return addresses often come out as [email protected]:

                        Goto the [mail function] section of the php.ini file, and change your sendmail_from variable to whatever you want it to be. This should now work. (I haven't tried it with unix, but it can't hurt, so you might want to do it anyways)
                        of course shared server it is not going to help
                        Christopher Padfield
                        Web Based Helpdesk
                        DeskPRO v3.0.3 Released - Download Demo Now!

                        Comment


                        • #13
                          Doesn't help much for me

                          Comment


                          • #14
                            Mail () Function Solution

                            Hey, Guys.

                            I had the same problem. The Reply-To: (see $extra below) fixed the problem.

                            Hope this helps.

                            $recipient = "Jimmy Jones <[email protected]>";
                            $subject = "Testing the mail function";
                            $message = "Hello!\n\nThis is the body of the message.\n\n";
                            $extra = "From: [email protected]\r\nReply-To: [email protected]\r\n";

                            mail ($recipient, $subject, $message, $extra);

                            Technobard

                            Comment


                            • #15
                              Reply-To did not work for me. Neither did sendmail_from work. I wanted to follow the instructions for the sendmail configuration, but couldn't find any of the files needed. Any ideas anyone? If someone got step 6 and 7 to work, can you tell us dummies a sendmail step 6 and 7 for dummies, thanks?

                              Comment

                              widgetinstance 262 (Related Topics) skipped due to lack of content & hide_module_if_empty option.
                              Working...
                              X