Postfix - Replace Reply-To - postfix-mta

I needed to replace the Reply-To header in PostFix
I have this
/etc/postfix/header_checks
/^Reply-To:[[:space:]]+(.*)/ REPLACE Reply-To: ${1} <sales#acme.com>
However the Mail header comes in as:
Reply-To: Administrator <support#acme.com> <sales#acme.com>

Got it
/^Reply-To:[[:space:]]+(.*)/ REPLACE Reply-To: <sales#acme.com>

Related

SMTP configuration | Ionos not receiving email

I'm experiencing some issues with Ionos smtp configuration.
I use Swiftmailer with Symfony 4.
On local i receive my email using mailtrap or gmail, but on ionos's server it doesn't work with gmail or the SMTP configuration.
Here is my .env with different configs :
###> symfony/swiftmailer-bundle ###
# For Gmail as a transport, use: "gmail://email#gmail.com:PSW#localhost" <-- Work in local but not on Ionos
# MAILER_URL=smtp://smtp.mailtrap.io:2525?encryption=tls&auth_mode=login&username=LOGINMAILTRAP&password=PASSWORDMAILTRAP <-- Work in local and Ionos
MAILER_URL=smtp://smtp.ionos.fr:587?encryption=ssl&auth_mode=login&username=contact#mydomain.com&password=PWD <-- Doesn't work using Ionos SMTP config
###< symfony/swiftmailer-bundle ###
Here is my swiftmailer.yaml :
swiftmailer:
url: '%env(MAILER_URL)%'
spool: { type: 'memory' }
https://symfony.com/doc/current/email.html#configuration
If the username, password or host contain any character considered special in a URI (such as +, #, $, #, /, :, *, !), you must encode them. See RFC 3986 for the full list of reserved characters or use the urlencode function to encode them.
Try changing the encryption, from ssl to tls.
Here is an example:
MAILER_URL=smtp://smtp.ionos.fr:587?encryption=tls&auth_mode=login&username=contact#mydomain.com&password=PWD
And make sure to urlencode the password if it contains any special charater, as mentioned by #Fisher

Apache2 Custom header - Adding Remort Port on header

I try to add a custom header on my request, but I'm not sure if it's possible with Apache2.4.
I would like to add to my headers the remote port used by the client.
If I check my logformat, I can get the remote port with this syntax :
%{remote}p
But if I try something like :
Header add x-remote-port %{remote}p
My configtest give me this error :
Unrecognized header format %p
I would like to know if it's possible to get a dynamic variable like remote port to add it on my headers for each requests ?
Log format syntax are differents, so here we go for the header module syntax :
Header add X-remote-port "%{REMOTE_PORT}e"
REMOTE_PORT varirable works only on 2.4.26 and later
https://httpd.apache.org/docs/2.4/expr.html

Configure MX and postfix

I have two domains, dom1.com and dom2.com; dom1.com has IP1; the email for dom1.com are handled by google.
I need to create an email, xxx#dom2.com and redirect all emails to an email account of dom1.com ( example: yyy#dom1.com )
I 'd like to use postfix, installed on dom1.com server.
I set the MX record for dom2.com in this way:
MX mail.dom2.com
mail A IP1
so mail.dom2.com should point to IP1.
To configure postfix on dom1.com server, I did as follow:
myhostname = dom1.com
mydestination = dom1.com, dom2.com
virtual_alias_domains = hash:/etc/postfix/virtual_domains
virtual_alias_maps = hash:/etc/postfix/virtual
in virtual_domains:
dom1.com #domain
dom2.com #domain
in virtual:
xxx#dom2.com yyy#dom1.com
than I did postmap for both files and I reload postfix ... but sending email to xxx#dom2.com , I don't reveice emails on yyy#dom1.com
Where is the error?
Thanks in advance
Option what you want to use is: Catch-all
This Tutorial will help you to setup catch-all email address with postfix.
Step 1. Configure Catch-All Account
Edit /etc/postfix/virtual and configure your catch-all address like below.
# nano /etc/postfix/virtual
#example.com myuser
If you want to add exception’s in catch-all and do not want to catch-all specific accounts, Add them also in /etc/postfix/virtual file. Below configuration will send all emails to user “myuser” except emails of info#example.com and support#example.com.
#example.com myuser
info#example.com info
support#example.com support
Save /etc/postfix/virtual file and execute following command.
# postmap /etc/postfix/virtual
2. Update Postfix Configuration File
Edit Postfix configuration file /etc/postfix/main.cf and add following line at end of file.
# nano /etc/postfix/main.cf
virtual_alias_maps = hash:/etc/postfix/virtual
3. Reload Postfix Server
After changing we need to reload server to activate newly settings addedUse following command to reload postfix configuration .
# service postfix reload

Passing Special Characters into telnet Unix

I use the following command to send SMS messages through SMS Adapters:
telnet localhost 0000 <<-EOF
helo x
MAIL FROM: Test
RCPT TO: 447999999999
DATA
Test £1234
.
logout
quit
EOF
However when ever I get the Message through it will be in the format:
Test ?£1234
Appending the ? to the front of the £ symbol, I have tried investigating a few methods including MIME however not quite sure how they can be implemented.
Any ideas on how I can stop and allow the successful passthroughs of £
Have you tried encoding the message first? You can do this using base64 in UTF-8 charset:-
e.g.
Convert:
msg="£1234"
To:
msg="wqMxMjM0"
NOTE:Try testing encoding/decoding using the online converter - https://www.base64encode.org/
Once you have encoded your text you can send the message via telnet by adding the MIME details after the DATA command in telnet by specifying MIME types, example script below:-
telnet localhost 0000 <<-EOF
helo x
MAIL FROM: Test
RCPT TO: 447999999999
DATA
Subject: Test
Mime-Version: 1.0
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: base64
${msg}
.
logout
quit
EOF
Hope that helps.
In some installations, telnet is not 8-bit clean by default (It does not recognize 8-bit character encodings such as Unicode). In order to be able to send Unicode keystrokes to the remote host, you need to set telnet into "outbinary" mode. There are two ways to do this:
$ telnet -L <host>
and
$ telnet
telnet> set outbinary
telnet> open <host>
Source

postfix virtualdomain - message bouncing - unknown user error in maillog

I have configured the virtual domain in postfix 2.x
Please check the configuration below:
virtual_mailbox_domains = ghhdomain.com, krdomain.com, murugeshdomain.com
#setup virtual domains mailbase for mailboxes
virtual_mailbox_base = /var/spool/mail
#create lookup file that maps email addresses to respective mailboxes
virtual_mailbox_map = hash:/etc/postfix/virtual
#who will be the owner of the mailbox file
virtual_uid_maps = static:503
virtual_gid_maps = static:503"
added to /etc/postfix/virtual
info#ghhdomain.com ghhdomain/info
info#krdomain.com krdomain/info"
done postmap /etc/postfix/virtual
while testing
Escape character is '^]'.
220 mail.murugeshdomain.com ESMTP Postfix
ehlo ghhdomain.com
250-mail.murugeshdomain.com
250-PIPELINING
250-SIZE 10240000
250-VRFY
250-ETRN
250-STARTTLS
250-ENHANCEDSTATUSCODES
250-8BITMIME
250 DSN
And.. When I do mail from: info#ghhdomain.com and rcpt to:info#ghhdomain.com
I get the enter code hereror in the log.
bounced - unknown user "info#ghhdomain.com
What is that missing,
TIA
Hari
Here you use the virtual_mailbox_map = hash:/etc/postfix/virtual, ie you use the virtual alias file for the virtual mailbox map. You are not suppose to do this.
So please use different files for virtual alias and virtual mailbox
So you can use,
virtual_mailbox_maps = hash:/etc/postfix/vmailbox
virtual_alias_maps = hash:/etc/postfix/virtual
/etc/postfix/vmailbox:
info#ghhdomain.com ghhdomain/info
info#krdomain.com krdomain/info
you can verify more details in this link
make aliases for local accounts/users
in /etc/postfix/main.cf edit :
virtual_alias_maps = mysql:/etc/postfix/virtual-alias-maps.cf
regexp:/etc/postfix/local-users-aliases
# ---- put everything on same line ---------
Now Postfix will build aliases list from mysql table (you can use and/or hash from file ... postfix accept a list of sources) and using regular expresion from file
write local-users-aliases
echo "/^(webmaster|www|ftp|postmaster|root|MAILER-DAEMON|abuse)/ u_mail#u_domain" >
/etc/postfix/local-users-aliases
after /etc/init.d/postfix restart any mail sent to postmaster fro ex will go to u_mail#u_domain

Resources