# postfix relay



## graudeejs (Apr 18, 2011)

Hi! I have my mail server configured according to https://wiki.bsdroot.lv/freebsd:mailserver
Now I'd like to configure my desktop pc to rely mail via my mail server.

Mailserver itself works pretty well, I can use it with any mail client... however I fail to configure my desktop pc Postfix to relay mail via mailserver (using submission port).

When I try to send mail I get fallowing error

```
From MAILER-DAEMON  Mon Apr 18 19:55:44 2011
Return-Path: <>
X-Original-To: killasmurf86@desktop.pc
Delivered-To: killasmurf86@desktop.pc
Received: by desktop.pc (Postfix)
	id D7D3310217E; Mon, 18 Apr 2011 19:55:44 +0300 (EEST)
Date: Mon, 18 Apr 2011 19:55:44 +0300 (EEST)
From: MAILER-DAEMON@desktop.pc (Mail Delivery System)
Subject: Undelivered Mail Returned to Sender
To: killasmurf86@desktop.pc
Auto-Submitted: auto-replied
MIME-Version: 1.0
Content-Type: multipart/report; report-type=delivery-status;
	boundary="8759110217C.1303145744/desktop.pc"
Message-Id: <20110418165544.D7D3310217E@desktop.pc>
Status: RO

This is a MIME-encapsulated message.

--8759110217C.1303145744/desktop.pc
Content-Description: Notification
Content-Type: text/plain; charset=us-ascii

This is the mail system at host desktop.pc.

I'm sorry to have to inform you that your message could not
be delivered to one or more recipients. It's attached below.

For further assistance, please send mail to postmaster.

If you do so, please include this problem report. You can
delete your own text from the attached returned message.

                   The mail system

[red]<zfsnap@bsdroot.lv>: host smtp.bsdroot.lv[83.241.11.135] said: 553 5.7.1
    <killasmurf86@desktop.pc>: Sender address rejected: not owned by user
    aldis@bsdroot.lv (in reply to RCPT TO command)[/red]

--8759110217C.1303145744/desktop.pc
Content-Description: Delivery report
Content-Type: message/delivery-status

Reporting-MTA: dns; desktop.pc
X-Postfix-Queue-ID: 8759110217C
X-Postfix-Sender: rfc822; killasmurf86@desktop.pc
Arrival-Date: Mon, 18 Apr 2011 19:55:44 +0300 (EEST)

Final-Recipient: rfc822; zfsnap@bsdroot.lv
Action: failed
Status: 5.7.1
Remote-MTA: dns; smtp.bsdroot.lv
Diagnostic-Code: smtp; 553 5.7.1 <killasmurf86@desktop.pc>: Sender address
    rejected: not owned by user aldis@bsdroot.lv

--8759110217C.1303145744/desktop.pc
Content-Description: Undelivered Message
Content-Type: message/rfc822

Return-Path: <killasmurf86@desktop.pc>
Received: by desktop.pc (Postfix, from userid 1001)
	id 8759110217C; Mon, 18 Apr 2011 19:55:44 +0300 (EEST)
Date: Mon, 18 Apr 2011 19:55:44 +0300
From: Aldis Berjoza <aldis@bsdroot.lv>
To: zfsnap@bsdroot.lv
Subject: test
Message-ID: <20110418165544.GA17670@desktop.pc>
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Disposition: inline
User-Agent: Mutt/1.5.21 (2010-09-15)

test
-- 
Aldis Berjoza


--8759110217C.1303145744/desktop.pc--
```

desktop pc config

```
desktop# postconf -n
command_directory = /usr/local/sbin
config_directory = /usr/local/etc/postfix
daemon_directory = /usr/local/libexec/postfix
data_directory = /var/db/postfix
debug_peer_level = 2
html_directory = /usr/local/share/doc/postfix
mail_owner = postfix
mailq_path = /usr/local/bin/mailq
manpage_directory = /usr/local/man
mynetworks_style = host
newaliases_path = /usr/local/bin/newaliases
queue_directory = /var/spool/postfix
readme_directory = /usr/local/share/doc/postfix
relayhost = [smtp.bsdroot.lv]:587
sample_directory = /usr/local/etc/postfix
sendmail_path = /usr/local/sbin/sendmail
setgid_group = maildrop
smtp_sasl_auth_enable = yes
smtp_sasl_password_maps = hash:/usr/local/etc/postfix/sasl_passwd
smtp_sasl_security_options = noanonymous
smtp_sasl_tls_security_options = noanonymous
smtp_tls_cert_file = /usr/local/etc/postfix/certs/newcert.pem
smtp_tls_enforce_peername = no
smtp_tls_key_file = /usr/local/etc/postfix/certs/privkey.key
smtp_tls_note_starttls_offer = yes
smtp_tls_scert_verifydepth = 5
smtp_use_tls = yes
smtpd_tls_ask_ccert = yes
smtpd_tls_req_ccert = no
tls_random_source = dev:/dev/urandom
unknown_local_recipient_reject_code = 550
```

servers config

```
allow_untrusted_routing = no
command_directory = /usr/local/sbin
config_directory = /usr/local/etc/postfix
content_filter = scan:[127.0.0.1]:10025
daemon_directory = /usr/local/libexec/postfix
data_directory = /var/db/postfix
debug_peer_level = 2
disable_vrfy_command = yes
home_mailbox = Maildir/
html_directory = /usr/local/share/doc/postfix
inet_interfaces = [B]some ip's[/B]
local_recipient_maps = $virtual_mailbox_maps
mail_owner = postfix
mailq_path = /usr/local/bin/mailq
manpage_directory = /usr/local/man
message_size_limit = 36700160
mydestination = localhost, localhost.$mydomain
mydomain = bsdroot.lv
mynetworks = [B]some ip's[/B]
myorigin = $mydomain
newaliases_path = /usr/local/bin/newaliases
queue_directory = /var/spool/postfix
readme_directory = /usr/local/share/doc/postfix
relay_domains = $mydestination
sample_directory = /usr/local/etc/postfix
sendmail_path = /usr/local/sbin/sendmail
setgid_group = maildrop
smtp_tls_note_starttls_offer = yes
smtp_use_tls = yes
smtpd_delay_reject = yes
smtpd_helo_required = yes
smtpd_helo_restrictions = permit_mynetworks,	check_helo_access hash:/usr/local/etc/postfix/helo_access,	reject_non_fqdn_hostname,	reject_invalid_hostname,	permit
smtpd_recipient_restrictions = reject_unauth_pipelining,	reject_non_fqdn_recipient,	reject_unknown_recipient_domain,	permit_mynetworks,	permit_sasl_authenticated,	reject_unauth_destination,	permit
smtpd_sasl_auth_enable = yes
smtpd_sasl_path = /var/run/dovecot/auth-client
smtpd_sasl_security_options = noanonymous, noplaintext
smtpd_sasl_tls_security_options = noanonymous
smtpd_sasl_type = dovecot
smtpd_sender_login_maps = pgsql:/usr/local/etc/postfix/pgsql_controlled_envelope_senders.cf
smtpd_sender_restrictions = reject_non_fqdn_sender,	reject_unknown_sender_domain,	permit_mynetworks,	reject_sender_login_mismatch,	permit_sasl_authenticated,	permit
smtpd_tls_CAfile = /etc/ssl/bsdroot/bsdroot.lv.pem
smtpd_tls_auth_only = yes
smtpd_tls_cert_file = /etc/ssl/bsdroot/bsdroot.lv.pem
smtpd_tls_key_file = /etc/ssl/bsdroot/bsdroot.lv.pem
smtpd_tls_loglevel = 0
smtpd_tls_received_header = yes
smtpd_tls_session_cache_timeout = 3600s
smtpd_use_tls = yes
strict_rfc821_envelopes = yes
tls_random_source = dev:/dev/urandom
unknown_local_recipient_reject_code = 550
virtual_alias_maps = pgsql:/usr/local/etc/postfix/pgsql_virtual_alias_maps.cf
virtual_gid_maps = static:6
virtual_mailbox_base = /srv/mail
virtual_mailbox_domains = pgsql:/usr/local/etc/postfix/pgsql_virtual_mailbox_domains.cf
virtual_mailbox_limit_maps = pgsql:/usr/local/etc/postfix/pgsql_virtual_mailbox_limit_maps.cf
virtual_mailbox_limit_override = yes
virtual_mailbox_maps = pgsql:/usr/local/etc/postfix/pgsql_virtual_mailbox_maps.cf
virtual_maildir_limit_message = Sorry, this user has overdrawn their diskspace quota. Please try again later.
virtual_overquota_bounce = yes
virtual_transport = dovecot
virtual_uid_maps = static:26
```

Any Ideas... I've googled few hours, but nothing so far seams to fix my problem.


----------



## aragon (Apr 19, 2011)

Looks like the problem is related to smtpd_sender_login_maps.  That directive makes Postfix restrict sender addresses to what is defined for the SASL login name that authenticates.  Either disable that feature, create an association for killasmurf86@desktop.pc on your aldis@bsdroot.lv SASL login, or make sure your desktop sends mail from aldis@bsdroot.lv.

You probably want the last option as killasmurf86@desktop.pc is an invalid e-mail address on the internet.


----------



## graudeejs (Apr 19, 2011)

aragon said:
			
		

> You probably want the last option as killasmurf86@desktop.pc is an invalid e-mail address on the internet.



I though that's what envelope was supposed to do

```
From: Aldis Berjoza <aldis@bsdroot.lv>
To: zfsnap@bsdroot.lv
```


----------



## graudeejs (Apr 19, 2011)

Solved this in very simple & clean manner

to main.cf on desktop pc I added

```
smtp_generic_maps = hash:/usr/local/etc/postfix/generic_maps
```

and created generic_maps

```
killasmurf86@desktop.pc aldis@bsdroot.lv
```
and run *postmap* on generic_maps to generate database

After reloading postfix, I can send mail from my desktop 
Yeeeeeey
Now back to using mail/mutt-devel full time 

Reference:
http://www.postfix.org/ADDRESS_REWRITING_README.html

EDIT
oh, ye and I did add *transport_maps*


----------

