Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I followed the following steps to send mail() from my localhsot

  1. installed PEAR

    sudo apt-get install php-pear
  2. Then Installed following things one by one using PEAR for mail() function to work.

    sudo pear install mail
    sudo pear install Net_SMTP
    sudo pear install Auth_SASL
    sudo pear install mail_mime
  3. Then Install postfix

    sudo apt-get install postfix

    During installation:

    1. Choose Internet Site
    2. Enter localhost at the input area of Mailserver.
  4. Configure /etc/php5/apache2/php.ini in order to configure sendmail path:

    sendmail_path = "/usr/sbin/sendmail -t -i"
  5. Restart apache server and test any mail script

    sudo service apache2 restart 

Here's the code:

  $from_name ="xyz";
  $from_mail = "xyz@essindia.co.in";
  //$to = "sanjay.sirohee@gmail.com";
  //$to = "sanjay.kumar3@essindia.co.in";
//$to = "prakash.kumar@essindia.co.in";
$to = "aggarwal.ankush@gmail.com, ankush.aggarwal@essindia.co.in";
  $subject = "Satish's Test Mail";
  $mail_body = "That is a email test";
  $message = $mail_body ;
  $headers = "MIME-Version: 1.0" . "\r\n";
  $headers .= "Content-type:text/html;charset=UTF-8\r\n";
  $headers .= "From: ".$from_name." <".$from_mail.">\r\n";

      echo "Send";
      echo "Not Send";  

Its is sending the mail to our company ID as within intranet but is not able to send email within same environment.

It gives the message that "Mail Successfully sent" but gmail and yahoo users are not able to receive the mail while our company email IDs are receiving the email.

Please tell the possibilities of errors.
What settings are required to be checked.

share|improve this question
Checked your spam folders? Sending email reliably is harder than you think! If it is going into spam, check the message headers and see what the spam detection headers say about the message. They're usually pretty informative. –  Oli Jun 27 '13 at 10:41

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.