Pergunta

I have been trying to use Office365 SMTP relay for a web server running postfix. I need to be able to send messages from my Office365 domain to other addresses in the domain, so I don't think port 25 anonymous SMTP is going to work.

If I run

echo "testing" | sendmail -fuser@mydomain.com me@mydomain.com

Then the message goes through (provided that user is listed in sasl_passwd)

However if I run a simple PHP script such as this:

<?php
$to = "me@mydomain.com";
$subject = "Test";
$message = "test from PHP";
$from = "user@mydomain.com";
$headers = "From:" . $from;
mail($to,$subject,$message,$headers);
echo "Mail Sent.";
?>

Then the delivery is bounced with

550 5.7.1 Client does not have permissions to send as this sender

I have read that the empty from=<> value (which I can see in the logs) is the cause of the problem, but I don't understand how to change that to anything from postfix settings. Am I understanding correctly that postfix relay settings are correct if the command-line works? Is there some other step for PHP configuration that I am missing?

From looking at the log file, it appears as though two messages are generated each time the PHP script is run. One has the correct from address and the other is empty.

Let me know if you need any other information. Thanks in advance.

-Seth

Foi útil?

Solução

Thanks to this other person (also answering their own question):

https://serverfault.com/questions/147921/forcing-the-from-address-when-postfix-relays-over-smtp/152126#152126

I am just posting this for anyone else who might stumble on my question.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top