postfix different smtp_sasl_mechanism_filter for different ISPs - postfix-mta

With this line in postfix's main.cf:
smtp_sasl_mechanism_filter = xoauth2
I can send email through gmail but not through dreamhost.
If I delete that line I can send through dreamhost but not through gmail.
Postfix documentation for smtp_sasl_mechanism_filter implies I can have a type:table lookup for the desired mechanisms, but I'm not sure what that table should look like. I've tried a file with a list of
[relayhost]:port mech1, mech2
but it doesn't work. Has anyone created such a lookup table successfully?

One answer is, courtesy of the postfix mailing list and postfix's author, to use different smtp delivery transports in master.cf, e.g:
Add to master.cf:
google unix - - n - - smtp
-o smtp_sasl_mechanism_filter=xoauth2
dreamhost unix - - n - - smtp
-o smtp_sasl_mechanism_filter=login
Add to main.cf:
sender_dependent_default_transport_maps=hash:/etc/postfix/sender_transport
Create sender_transport with:
#domain1 google:[gmail-smtp.l.google.com]:587
#domain2 dreamhost:[smtp.dreamhost.com]:587

Related

Datapower SSH login ignores username

When I ssh to my Datapower node like so: ssh user#192.168.0.1 I receive this response:
ssh user#192.168.0.1
(unknown)
Unauthorized access prohibited.
login:
I then enter in the same username, and am also prompted for a password. I type in my credentials and it works! Why didn't it just read my username the first time?
This is hampering my ability to automate a few basic tasks with shell scripts such as fetching logs for processing.
I agree with #Ken and #Stefan that a XML Management is a more appropriate tool for long term automations, howerver, sometimes we need something quick or temporary (or both) ... and for that a CLI automation is easier and faster to develop.
An easy way to push commands to CLI from a shell script is directing the input and output, like this quick sample:
#!/bin/ksh
DPHOST=datapower.device.company.com
DP_USER_ID="myuser"
DP_PASSWORD="mypasword"
TMPFILE=/tmp/tempfile.dp
OUTFILE=/tmp/outfile.dp
TS=`date +%Y%m%d%H%M%S`
cat << EOF > $TMPFILE
DP_USER_ID
DP_PASSWORD
default
echo show cpu
show cpu
echo show memory
show memory
EOF
ssh -T $DPHOST < $TMPFILE > $OUTFILE.$TS
rm $TMPFILE
Note that if you do not have any application domains defined, you may suppress the "default" after the password
And of course, for security reasons you may request the user and password at run time, rather then have it saved on a plain text file, but that is up to you ... the relevant piece here is that you can redirect the file with the commands to an regular ssh session
If you prefer, something like cat $TMPFILE | ssh -T $DPHOST > $OUTFILE.$TS would also works.
That is because DataPower really isn't a SSH server only using the protocol.
What I do in my scripts is that I do the connection, wait for the response and then send the username as the second command and password as third:
ssh [datapower ip]
(unknown)
Unauthorized access prohibited.
login:
your-username
password:
your-password
'#xi52:
DataPower ignores the passed-in username.
Will using the XML Management interface meet your needs? I probably have some scripts laying around.
Ken

Postfix: how to block incoming emails to a specific recipient?

I have Postfix set up to deliver all incoming email to 〈any_random_address〉#mydomain.com to myname#mydomain.com. I've recently noticed that a large percentage of spam is going to the same non-existent username, and I'd like to block incoming email to that username, while still sending all other emails to my inbox. What is the best way to accomplish that?
Aside from the fact that catch-all doesn't really make sense:
In your virtual aliases map (e.g. /etc/postfix/virtual_alias_maps), add the following line:
john.doe#example.com devnull
In /etc/aliases, add the following line:
devnull: /dev/null
This defines a mailbox named devnull and stores its contents in /dev/null.
Don't forget to update the alias caches and restart Postfix, for example like
sudo postmap /etc/postfix/virtual_alias_maps
sudo newaliases
sudo service postfix restart
Now you should be fine.

Qmail email address without hostname/domain name

In our production a user sent an email to the following address "xxx" (Literally the email is address xxx). This address is within our companies organization (xxx#company.com.ph), I am being asked how it was sent without "#company.com.ph".
I told them it was probably the configuration of our SMTP server as I am sure the application I made is not appending "#company.com.ph" to mails without (hostName/domainName).
Our SMTP server is Qmail in a Unix box. Can anyone tell me what configurations we could check to explain how this happened?
Unfortunately, I do not have a Qmail or Unixbox so I cant test it myself and I don't have access to our production servers so I could really use some help.
PS. Can anyone also give me the correct term for "#company.com.ph" is it the hostName/domainName?
Checks Done
1) According to the administrator - "defaultdomain" is set to "mail.company"
Yes by default qmail will add defaultdomain to any recipient address missing the domain part.
#company.com.ph is the domain name part of the email address.
defaultdomain file by default is in /var/qmail/control directory as from documentation: http://www.lifewithqmail.org/lwq.html#config-files

OpenDKIM set d=[senderServer.com] tag to use the default sender server instead the FROM email domain

Here is the issue:
I have an email server with OpenDKIM and Postfix installed as here:
http://www.serveridol.com/2012/02/17/opendkim-configuring-dkim-keys-on-postfix/
My TXT DNS record is on the main domain (Server domain name)
Here: senderServer.com
It works great when I send an email from senderServer.com using my FROM address as: anything#senderServer.com
The problem is when I send an email using my FROM address as: anything#otherDomain.com
The DKIM signature is added but using otherDomain as the domain value tag:
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple;
d=otherDomain.com; s=20131125; t=1385596727;
bh=g3zLYH4xKxcPrHOD18z9YfpQcnk/GaJedfustWU5uGs=;
h=Date:To:Subject:From;
b=ujfsdhfu9hf9sdfs9df9sfs9fhsd9hfsfnsvkjnsdlvljsv
so, the server that is receiving the messages is not finding the DNS record which is obviously clear since the d= tag value is otherDomain.com instead senderServer.com
I would like to find the way to retrieve the d= value from the server name instead retrieve it from the FROM header email address... or override it to be always d=senderServer.com
Domain *
KeyFile /etc/postfix/dkim.key
Selector mail
in /etc/opendkim.conf to use the same key for multiple domains ( documentation )
and added no_milters to /etc/postfix/master.cf
made this line:
-o receive_override_options=no_header_body_checks,no_unknown_recipient_checks
look like:
-o receive_override_options=no_header_body_checks,no_unknown_recipient_checks,no_milters
This prevented opendkim signing messages twice.

Configure Mail Server to receive mail from any domain [closed]

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 9 years ago.
Improve this question
I have a postfix mail server on ubuntu on my virtualbox,now the domain of the mail server is abc.com...hence it receives mail from any "from address" but the "to address" needs to be proper i.e a valid user in the mailserver.
Now,in my project i am sending fake mails to user whose mail id consists of other domains too...like cde.com
My final objective is to show the mails in the mail server.
When i tried that ,it goes directly in to the mailserveer logs i.e /var/log/mail.log i.e as an error
is there any way i can store these mails in the mailserver??
You want not only a Catch-All configuration like accepting any mail to *#abc.com but also to have a Catch-Anything configuration to accept any mail to *#* ?
This is possible if you have the PCRE support compiled into Postfix. Then you need virtual users in your configuration (see the Posfix documentation) and tweak it as follows:
Make sure that your Postfix is already configured to accept mail for at least one user and one domain. And that this is tested.
1) In main.conf set
virtual_alias_domains =
virtual_alias_maps = hash:/etc/postfix/virtual_forwardings, pcre:/etc/postfix/virtual_forwardings.pcre
virtual_mailbox_domains = hash:/etc/postfix/virtual_domains, pcre:/etc/postfix/virtual_domains.pcre
The hash: parts are the known from the docs. And the pcre: parts are new.
The hash: parts can also be omitted.
2) Create the file virtual_domains.pcre with the following content:
/^.*/ OK
This accepts any domain as valid recipient domain.
3) Create the file virtual_forwardings.pcre with the following content:
/#.*/ someuser#example.com
This forwards any local part of any domain to the Postfix user someuser#example.com. Make sure that this is a valid virtual or local user.
In this configuration it seems that Postfix is an Open Relay, but it does not relay for other domains. It accepts mails for any domain and locally delivers the mail to one mailbox.
Sometimes you will then notice a log entry telling you something like "don't list abc.com in mydestination and virtual config". This warning can be ignored as this "strange" setup is not usual.
FTR:
An alternative way to do it by sending any mail to "some.local.user" (a shell user)
Required: postfix-pcre package
in main.cf
luser_relay = some.local.user
local_recipient_maps =
virtual_alias_maps = pcre:/etc/postfix/virtual_alias.pcre
mydestination = $myhostname, pcre:/etc/postfix/mydestination.pcre
File: /etc/postfix/virtual_alias.pcre
(catchall mapped to "some.local.user")
/\/#/ some.local.user
__
File: /etc/postfix/mydestination.pcre (we accept whatever you throw at us)
/.*/ OK

Resources