Sending mails with PHP, LAMPP and PostFix

In your php.ini, this:

sendmail_path = /etc/postfix

Should be the path to the sendmail (or compatible) binary.
You've set it to the configuration directory of postfix which isn't right.

For historical reasons, usually /usr/bin/sendmail is maintained as a compatibility link.
sendmail was around first (I guess) and pretty much everything just assumes it is in the installed MTA. So when it isn't, the replacement makes a symlink so that nothing breaks.


To send mail from localhost (WAMP, XAMP, or LAMP) you can use PHPMailer package

  • Click here to download from github https://github.com/shashidhark/PhpMailer and Follow the instruction given in the readme file.

This will be same instruction given in readme file..

WAMP (windows):

First you have to edit the "php.ini" To find this file display the phpinfo by using following code from the WAMP server. Create one php file [setting.php] inside C:/wamp/www/ and add the following content to that file.

<?php
     echo phpinfo();
?>

Type localhost/setting.php at browser. There search for "Loaded Configuration File" That will be the path to your php.ini.

In php.ini file remove the ;(semi colon) given to `extension=php_openssl.dll. Now server setting is over...

  • After downloading PHPMailer folder from github,
  • Extract->Copy the full folder into your project folder i.e C:/wamp/www/
  • Find the index.php file.
  • Change the parameter as your need.
  • Then in the browser type localhost/PHPMailer/index.php.
  • Then it will show successful message if email sent, else it will give error message.

LAMP (Linux):

  • In case of linux, There is no need to edit the php.ini file as i explained first point under WAMP.

  • One more change is project or Document root folder is different.

  • In Linux the default Document root folder will be /var/www
  • You can change the Document root folder easily. For that visit https://stackoverflow.com/a/17612396/1925943
  • Copy the PhpMailer to this document root folder and edit index.php as your need.
  • Then type localhost/PhpMailer/index.php in browser.