I have a script like that :
<html>
<body>
<?php
$addresses = ['[email protected]'];
foreach ($addresses as $address) {
sendMail($address);?><br /><?php
}
?>
<?php
function sendMail($address) {
mail($address, "object", "message");
print $address;
}
?>
</body>
</html>
I installed and configured the mail server haraka. I think that my configuration is ok : When I use the command swaks -tls -f [email protected] -t [email protected] -s localhost -p 587 -au testuser -ap testpassword
, i receive correctly the mail.
But when I send a mail via the mail function in PHP, I don't receive anything.
In my php.ini
, I configure :
;[mail function]
SMTP = localhost
smtp_port = 587
username = testuser
password = testpassword
sendmail_from = [email protected]
After script's execution, when I check haraka's logs, I don't see anything. But in the file /var/log/maillog
, I can see that sendmail's logs are adds.
Can you tell me how o configure PHP to use correctly my local mail server Haraka ?
it would not work with php's mail function , try to work with this instead to Send messages over SMTP PHPMailer or swiftMailer , check this too
read docs for more information