r***@jaeb.ca
2015-09-23 12:14:49 UTC
Hi,
Please correct me if I misuse any terminology.
I'm trying to configure postfix to act as a smarthost / nullmailer, but I can't get it to work all the time. It works most of the time, but there's one specific scenario where it fails and I can't figure out how to fix it. I'm using the following noteworthy config in main.cf:
# Use ZOHO as a relay.
relayhost = [smtp.zoho.com]:587
smtp_use_tls = yes
smtp_sasl_auth_enable = yes
smtp_sasl_password_maps = hash:/etc/postfix/zoho_credentials
smtp_tls_CAfile = /etc/ssl/certs/ca-bundle.crt
smtp_sasl_security_options = noanonymous
smtp_sasl_tls_security_options = noanonymous
smtp_generic_maps = hash:/etc/postfix/generic
I have a single line in /etc/postfix/generic:
@localhost.localnet ***@example.com
I also have a single line in /etc/aliases:
root: ***@example.com
However, I have trouble sending mail with heirloom-mailx on CentOS 7. For example, when I'm logged in as the user 'ryan' I'll try to send a test message using the following:
mail -s "Testing" root <<< "Test email to root."
This fails because the from address ends up being written in a format that isn't accepted by ZOHO. I think what's happening is that my name is read from the GECOS field of /etc/password and appended to the from address. ZOHO rejects the message with the following (truncated) error:
Relaying disallowed as ***@example.com (Ryan)
I assume the address started as "ryan (Ryan)" or "***@localhost.localnet (Ryan)", but the logs only show the bare address before it's rewritten. Is "***@example.com (Ryan)" a valid format for an address? Is ZOHO being too strict or is heirloom-mailx formatting the address incorrectly?
If I specify any kind of accepted (by ZOHO) format for the from address it works as expected. For example, I can use:
mail -r foobar -s "Testing" root <<< "Test email to root."
mail -r "Ryan <foobar>" -s "Testing" root <<< "Test email to root."
Both of those work as expected and the sender addresses are rewritten to "***@example.com" and "Ryan <***@example.com>".
Ideally I'd like to always have mail sent as "HOSTNAME <***@example.com". Is my approach reasonable or is there an easier way to accomplish the same thing? Can I rewrite sender addresses to get rid of the trailing "(Ryan)" part of the examples shown above?
Put another way, I want to send all of root's mail to "***@example.com" and to force "HOSTNAME <***@example.com>" as the sender for all outgoing mail.
As an added bonus, I wouldn't mind rejecting all mail that's NOT sent to "root".
Please correct me if I misuse any terminology.
I'm trying to configure postfix to act as a smarthost / nullmailer, but I can't get it to work all the time. It works most of the time, but there's one specific scenario where it fails and I can't figure out how to fix it. I'm using the following noteworthy config in main.cf:
# Use ZOHO as a relay.
relayhost = [smtp.zoho.com]:587
smtp_use_tls = yes
smtp_sasl_auth_enable = yes
smtp_sasl_password_maps = hash:/etc/postfix/zoho_credentials
smtp_tls_CAfile = /etc/ssl/certs/ca-bundle.crt
smtp_sasl_security_options = noanonymous
smtp_sasl_tls_security_options = noanonymous
smtp_generic_maps = hash:/etc/postfix/generic
I have a single line in /etc/postfix/generic:
@localhost.localnet ***@example.com
I also have a single line in /etc/aliases:
root: ***@example.com
However, I have trouble sending mail with heirloom-mailx on CentOS 7. For example, when I'm logged in as the user 'ryan' I'll try to send a test message using the following:
mail -s "Testing" root <<< "Test email to root."
This fails because the from address ends up being written in a format that isn't accepted by ZOHO. I think what's happening is that my name is read from the GECOS field of /etc/password and appended to the from address. ZOHO rejects the message with the following (truncated) error:
Relaying disallowed as ***@example.com (Ryan)
I assume the address started as "ryan (Ryan)" or "***@localhost.localnet (Ryan)", but the logs only show the bare address before it's rewritten. Is "***@example.com (Ryan)" a valid format for an address? Is ZOHO being too strict or is heirloom-mailx formatting the address incorrectly?
If I specify any kind of accepted (by ZOHO) format for the from address it works as expected. For example, I can use:
mail -r foobar -s "Testing" root <<< "Test email to root."
mail -r "Ryan <foobar>" -s "Testing" root <<< "Test email to root."
Both of those work as expected and the sender addresses are rewritten to "***@example.com" and "Ryan <***@example.com>".
Ideally I'd like to always have mail sent as "HOSTNAME <***@example.com". Is my approach reasonable or is there an easier way to accomplish the same thing? Can I rewrite sender addresses to get rid of the trailing "(Ryan)" part of the examples shown above?
Put another way, I want to send all of root's mail to "***@example.com" and to force "HOSTNAME <***@example.com>" as the sender for all outgoing mail.
As an added bonus, I wouldn't mind rejecting all mail that's NOT sent to "root".