LinkShare_468x60v1

Tuesday, December 29, 2015

How to rewrite outgoing email address

When we call mail function by php on Linux , we can use postfix.

However, the sender will be always apache or www-data, since the system use default web user name as the sender name.

We can rewrite email of the sender by steps below.

Step 1

Check configuration in php.ini

[mail function]
; For Win32 only.
SMTP = localhost

; For Win32 only.
;sendmail_from = ***@yourdomain.com

; For Unix only. You may supply arguments as well (default: "sendmail -t -i").
;sendmail_path =\r



Step 2

Edit main.cf for postfix

vi /etc/postfix/main.cf



Step 3

Specify the generic map file in main.cf

smtp_generic_maps = hash:/etc/postfix/generic



Step 4

Edit generic file

vi /etc/postfix/generic


Step 5

Specify the mapping address

[email protected]   [email protected]


Step 6

Create postfix db hash file

postmap /etc/postfix/generic


Step 7

Restart postfix

/etc/init.d/postfix restart



You will need use sender_canonical_maps = hash:/etc/postfix/canonical instead if your postfix is earlier version.






No comments:

Post a Comment