Northumber
Northumber

Reputation: 315

How to configure and send mail with Postfix using a PHPmailer?

I have a PHPmailer class, downloaded from an example. I configured and installed Postfix and mailutils, but I don't know the parameters to configure the phpmailer with postfix. I tried as it is and I get the error: SMTP Error: Could not authenticate.

  public $From          = '[email protected]';
  public $FromName      = 'Me';
  public $Host          = 'localhost';
  public $Port          = 25;
  public $Helo          = '';
  public $SMTPSecure    = ''; // empty, ssl or tls
  public $SMTPAuth      = false;
  public $Username      = '';
  public $Password      = '';

How I have to configure /etc/postfix/main.cf config file and what I have to insert in the PHPmailer fields?

Upvotes: 2

Views: 11346

Answers (1)

nrm
nrm

Reputation: 153

PHPmailer will send mail by invoking the php mail() function and using postfix as the user that is making the request. For example, on an Ubuntu based system that will be www-data if called by apache using PHP. In short, no authentication is required as long as SMTPAuth = true; is NOT set. SMTPAuth is only required if you are connecting to a remote mail server to authenticate and deliver the mail.

To solve your problem. Remove the lines that relate to SMTPAuth to use the locally install postfix server.

You can reference https://github.com/PHPMailer/PHPMailer/tree/master/examples for various examples using PHPmailer.

Upvotes: 5

Related Questions