R
R
robert_n2016-02-12 22:48:41
PHP
robert_n, 2016-02-12 22:48:41

Configuring postfix to send emails?

Hello!)
I want to send emails to users from my server. I set up Yandex.Mail for my domain, and installed and configured postfix on the server following this instruction . Letters are sent, everything works, but the From header indicates:
www-data <[email protected]>
I want it to be:
Support <[email protected]>
I found an answer on SO that partially solves my problem. In main.cf I added a line:
smtp_generic_maps = hash:/etc/postfix/generic
And in the /etc/postfix/generic file I wrote:
www-data [email protected]
Now I receive letters with the heading "From www-data [email protected] ". Tried to register aliases, but it doesn't work either.

alias_maps = hash:/etc/postfix/aliases
alias_database = hash:/etc/postfix/aliases

Content aliases: I
www-data: Support
also tried to add a from header in the php function, but then the mail services either throw such a letter into spam, or write that it was probably sent by intruders.
$to = "[email protected]";
$subject = "Ваша учетная запись активирована";
$message = "Ваши данные: login и password";
$headers = "From: Support <[email protected]>\r\nContent-type: text/html; charset=windows-1251 \r\n";
mail ($to, $subject, $message, $headers);

Answer the question

In order to leave comments, you need to log in

1 answer(s)
O
Oleg Batalov, 2016-02-15
@badmilkman

The problem is not with Postfix.
Your PHP sends mail from the user under which it is running.
Simple crutch - change sendmail_path
In my php-fpm:
php_admin_value[sendmail_path] = /usr/sbin/sendmail -t -i -f [email protected]
But it's better to work from PHP directly with Yandex server

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question