ubuntu - postfix 2.9.6.1 forward all mail to an external mail address -
i trying tell postfix mails address should forwarded external email address.
my main.cf includes entry
smtpd_banner = $myhostname esmtp $mail_name (ubuntu) biff = no # appending .domain mua's job. append_dot_mydomain = no # uncomment next line generate "delayed mail" warnings #delay_warning_time = 4h readme_directory = no # tls parameters smtpd_tls_cert_file=/etc/ssl/certs/ssl-cert-snakeoil.pem smtpd_tls_key_file=/etc/ssl/private/ssl-cert-snakeoil.key smtpd_use_tls=yes smtpd_tls_session_cache_database = btree:${data_directory}/smtpd_scache smtp_tls_session_cache_database = btree:${data_directory}/smtp_scache # see /usr/share/doc/postfix/tls_readme.gz in postfix-doc package # information on enabling ssl in smtp client. myhostname = xshaunm-q1532n alias_maps = hash:/etc/aliases alias_database = hash:/etc/aliases mydestination = xshaunm-q1532n, localhost.localdomain, , localhost relayhost = mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128 mailbox_size_limit = 0 recipient_delimiter = + inet_interfaces = virtual_alias_domains = xshaunm-q1532n.pvt.lan virtual_alias_maps = hash:/etc/postfix/virtual my /etc/postfix/virtual looks follows:
(.*) testaddress@gmail.com i run following command
postmap /etc/postfix/virtual
restart postfix
/etc/init.d/postfix restart
now if run command
echo test | sendmail test@mydomain.com it should deliver testaddress@gmail.com, reason delivers test@mydomain.com, incorrect
if list exact address in /etc/postfix/virtual follows works, there hundreds of mail addresses needs catch , forward, regular expression better:
test@mydomain.com testaddress@gmail.com
finally found answer.
listing here posterity.
add folowing line end of main.cf file
vi /etc/postfix/main.cf virtual_maps = hash:/etc/postfix/virtual, regexp:/etc/postfix/virtual-regexp create file lists mail address want mails sent to
vi /etc/postfix/virtual-regexp add following:
/.+@.+/ forwardingmailaddress@gmail.com add postmap
postmap /etc/postfix/virtual-regexp you need add virtual file.
touch /etc/postfix/virtual now add postmap
postmap /etc/postfix/virtual
Comments
Post a Comment