I have a piece of software that I am developing that depends on the mail function in php. In my current webhost setup, I am on a server shared by hundreds if not thousands. Therefore when I send emails with the mail function the domain that they are from when you look at the email's source is brianru@cheetah.ultrawhb.com. This is unacceptable for me, so I am looking into purchasing a dedicated server. If I did this would I be able to change that domain, at least to the domain name that I own?

    Certainly. Make sure you get a host that allows you to have root access too.

      In the mean time have you tried changing the header?

      Snippet:

      $headers .="From: ME :) <noreply@email.co.uk>\r\n";

      Full Function:

      # Email System
      function c4email($email_to, $title, $message)
      {
      # Checking Vars
      if (!$email_to) { c4error("You must define an email address."); }
      if (!$title) { c4error("You must define an email title."); }
      if (!$message) { c4error("You must define a message."); }
      # Set Email Headers
      $headers  = "MIME-Version: 1.0\r\n";
      $headers .= "Content-type: text/html; charset=iso-8859-1\r\n";
      $headers .="From: iiCUP <noreply@iigaming.co.uk>\r\n";
      $messagen="
      <BODY BGPROPERTIES='fixed' bgcolor='#000000'>
      <FONT FACE='MS Sans Serif,Courier,System' COLOR='#FFFFFF'>
      $message
      </font></body>";
      # Send Mail
      if(mail($email_to,$title,$messagen, $headers)) {
      }
      }

        I have changed the header, but when sending messages to cell phones, what this is designed to do, they will display the actual from and then the header, instead of the header on top of the true from address.

        Also I will have root access on the server.

          does anybody know what the mail function uses as the domain when sending an email?

            That depends on what is in the php.ini, but you can use ini_set() to change it.

            SMTP = mail.somehost.com
            real php.ini below

            [mail function]
            ; For Win32 only.
            SMTP = mail.somehost.com
            smtp_port = 25

            ; For Win32 only.
            sendmail_from = me@somehost.com// put your email here

            ; For Unix only. You may supply arguments as well (default: "sendmail -t -i").
            ;sendmail_path = "C:\Program Files\xampp\sendmail\sendmail.exe -t"

            ; Force the addition of the specified parameters to be passed as extra parameters
            ; to the sendmail binary. These parameters will always replace the value of
            ; the 5th parameter to mail(), even in safe mode.
            ;mail.force_extra_parameters =

              alright, I found how to do all of this, but now the server I'm using uses qmail, not sendmail. so I'm now dealing with getting the php.ini file to use qmail. anybody know how to?

                Write a Reply...