Reputation: 71
I have a VPS where I've installed my site files, including the PHP email script that uses the php mail() function inside of the following directory (how my site directory/path is set up):
/var/www/mywebsite.com/html/
*DIRECTORY/PATH STRUCTURE SHOWN IN THE IMAGE BELOW: https://ibb.co/2SDjb8z
And when I installed Postfix, I've configured it to send email through Amazon SES. Postfix has been installed inside of the following directory:
/etc/postfix/
*DIRECTORY/PATH STRUCTURE SHOWN IN THE IMAGE BELOW: https://ibb.co/XF1JFvv
The problem that I'm having is that it will send email from the command line when testing that Postfix has been properly installed along with using the Amazon SES SMTP, BUT my php email script DOESN'T connect from my websites folder directory to Postfix.
How do I connect my php email script to Postfix? Do I need to change directories?
Here is the php mail() function script that I'm using below:
<?php
$to = "[email protected]";
$subject = "Another Test!";
$txt = "Hello world!";
$headers = "From: [email protected]" . "\r\n" .
"CC: AnotherTestEmailAddress.com";
mail($to,$subject,$txt,$headers);
?>
Note that the above php script, is the in the file called “email1.php” inside of my website folder. I’m just trying to connect it to Postfix which is located in the “/etc/postfix” directory.
Upvotes: 1
Views: 7063
Reputation: 943635
When you installed Postfix it should have created a sendmail
command line program.
Locate it and set the path to it in php.ini for the sendmail_path
option.
sendmail_path
string
Where the sendmail program can be found, usually/usr/sbin/sendmail
or/usr/lib/sendmail
. configure does an honest attempt of locating this one for you and set a default, but if it fails, you can set it here.Systems not using sendmail should set this directive to the sendmail wrapper/replacement their mail system offers, if any. For example, » Qmail users can normally set it to
/var/qmail/bin/sendmail
or/var/qmail/bin/qmail-inject
.
Upvotes: 5