Unable to send/receive email after re-installing Postfix

I first installed Virtualmin on my server which I used to install Postfix + Dovecot and later Roundcube. All was working well, until due to a wordpress plugin issue my server began to send SPAM email.

After following a number of tutorials I, noobishly, unisntalled Postfix (to prevent emails from being sent) while I debug.

Now I’m at a place where I’ve re-installed Postfix but to get it to work seems impossible, I’ve been stuck for days now.

I’m no longer able to send or receive emails.

Whenever I now login to my mail client (Roundcube) I notice from mail.log which makes it seem as if I’m being immedidately disconnected:

Jul  6 12:03:55 zh dovecot: imap-login: Login: user=<test>, method=PLAIN, rip=127.0.0.1, lip=127.0.0.1, mpid=16236, secured, session=<eGB7DTcaWgB/AAAB>
Jul  6 12:03:55 zh dovecot: imap(test): Disconnected: Logged out in=82 out=609
Jul  6 12:03:55 zh dovecot: imap-login: Login: user=<test>, method=PLAIN, rip=127.0.0.1, lip=127.0.0.1, mpid=16241, secured, session=<ouF9DTcaWwB/AAAB>
Jul  6 12:03:55 zh dovecot: imap(test): Disconnected: Logged out in=44 out=556
Jul  6 12:03:56 zh dovecot: imap-login: Login: user=<test>, method=PLAIN, rip=127.0.0.1, lip=127.0.0.1, mpid=16247, secured, session=<n6qGDTcaXAB/AAAB>
Jul  6 12:03:56 zh dovecot: imap-login: Login: user=<test>, method=PLAIN, rip=127.0.0.1, lip=127.0.0.1, mpid=16248, secured, session=<Er2GDTcaXQB/AAAB>
Jul  6 12:03:56 zh dovecot: imap(test): Disconnected: Logged out in=50 out=469
Jul  6 12:03:56 zh dovecot: imap(test): Disconnected: Logged out in=233 out=885

Whenever I send mail, in this case through Roundcube, I get this from my mail.logfile:

Jul 3 16:43:20 zm postfix/smtpd[30489]: connect from localhost[127.0.0.1]
Jul 3 16:43:20 zm postfix/smtpd[30489]: disconnect from localhost[127.0.0.1]

This error produce this Roundcube error message:

SMTP Error (250): Authentication failed.

In my mail.err log file I have this:

Jul 2 01:08:25 zm postfix/master[18886]: fatal: bind 0.0.0.0 port 25: Address already in use
Jul 2 01:09:07 zm postfix/postqueue[19034]: warning: Mail system is down -- accessing queue directly
Jul 2 01:09:27 zm postfix/postfix-script[19065]: fatal: the Postfix mail system is not running
Jul 2 01:09:33 zm postfix/master[19159]: fatal: bind 0.0.0.0 port 25: Address already in use
Jul 2 01:16:31 zm postfix/postfix-script[19660]: error: unknown command: ''
Jul 2 01:16:31 zm postfix/postfix-script[19661]: fatal: usage: postfix start (or stop, reload, abort, flush, check, status, set-permission
s, upgrade-configuration)
Jul 2 01:16:35 zm postfix/postfix-script[19667]: error: unknown command: ''
Jul 2 01:16:35 zm postfix/postfix-script[19668]: fatal: usage: postfix start (or stop, reload, abort, flush, check, status, set-permission
s, upgrade-configuration)
Jul 2 01:19:30 zm postfix/master[20032]: fatal: bind 0.0.0.0 port 25: Address already in use
Jul 2 01:19:31 zm postfix/master[20031]: fatal: daemon initialization failure
Jul 2 01:19:32 zm postfix/postfix-script[20033]: fatal: mail system startup failed
Jul 2 01:19:44 zm postfix/master[20141]: fatal: bind 0.0.0.0 port 25: Address already in use
Jul 2 01:19:50 zm postfix/master[20242]: fatal: bind 0.0.0.0 port 25: Address already in use
Jul 2 01:19:51 zm postfix/master[20241]: fatal: daemon initialization failure
Jul 2 01:19:52 zm postfix/postfix-script[20243]: fatal: mail system startup failed
Jul 2 01:20:00 zm postfix/master[20370]: fatal: bind 0.0.0.0 port 25: Address already in use

When I run *virtualmin check-config *this is some of the output:

"Mail server Postfix is installed and configured.
Postfix can support per-domain outgoing IP addresses, but is not currently configured to do so. This can be setup in the Postfix Mailserver module."

vi /etc/postfix/main.cf

smtpdbanner = $myhostname ESMTP $mailname (Ubuntu)
biff = no
appending .domain is the MUA's job.

appenddotmydomain = no
Uncomment the next line to generate "delayed mail" warnings
delaywarningtime = 4h

readme_directory = no
TLS parameters

smtpdtlscertfile=/etc/ssl/certs/ssl-cert-snakeoil.pem
smtpdtlskeyfile=/etc/ssl/private/ssl-cert-snakeoil.key
smtpdusetls=yes
smtpdtlssessioncachedatabase = btree:${datadirectory}/smtpdscache
smtptlssessioncachedatabase = btree:${datadirectory}/smtpscache
See /usr/share/doc/postfix/TLS_README.gz in the postfix-doc package for
information on enabling SSL in the smtp client.

smtpdrelayrestrictions = permitmynetworks permitsaslauthenticated deferunauthdestination
myhostname = ichangedmydomain.com
aliasmaps = hash:/etc/aliases
virtualaliasmaps = hash:/etc/aliases

virtualaliasmaps = hash:/etc/postfix/virtual
aliasdatabase = hash:/etc/aliases
myorigin = /etc/mailname
mydestination = ichangedmydomain.com, localhost.com, , localhost
relayhost =
mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128
mailboxcommand = procmail -a "$EXTENSION"
mailboxsizelimit = 0
recipientdelimiter = +
inetinterfaces = all
inet_protocols = all

Please I’d appreciate any help. (I’m not in a position to pay, this is for learning purposes mostly).

Thank you in advance.

Howdy,

First off, for future reference, you can stop the flow of outgoing email by shutting off the Postfix service. You don’t actually need to uninstall it.

As far as the problem you’re seeing now – what is the output of this command:

postconf -n

thank you for that tip, in hindsight I wish I knew better:

The following is from
postconf -n

alias_database = hash:/etc/aliases.db
alias_maps = hash:/etc/aliases
biff = no
config_directory = /etc/postfix
home_mailbox = Maildir/
inet_protocols = all
mailbox_command = procmail -a "$EXTENSION"
mailbox_size_limit = 0
mydestination = $myhostname, localhost.$mydomain, $mydomain, localhost
myhostname = im-shamefully-hiding-my-real-domain.com
mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128
myorigin = $mydomain
readme_directory = no
recipient_delimiter = +
smtp_tls_session_cache_database = btree:${data_directory}/smtp_scache
smtpd_banner = $myhostname ESMTP $mail_name (Ubuntu)
smtpd_relay_restrictions = permit_mynetworks permit_sasl_authenticated defer_unauth_destination
smtpd_tls_cert_file = /etc/ssl/certs/ssl-cert-snakeoil.pem
smtpd_tls_key_file = /etc/ssl/private/ssl-cert-snakeoil.key
smtpd_tls_session_cache_database = btree:${data_directory}/smtpd_scache
smtpd_use_tls = yes
virtual_alias_maps = hash:/etc/postfix/virtual

d

Okay, make sure that these options are added to your main.cf file:

smtpd_sasl_auth_enable = yes smtpd_sasl_security_options = noanonymous

And then, you have a mailbox_command line now, but it appears to be incorrect… try setting it to the following:

mailbox_command = /usr/bin/procmail-wrapper -o -a $DOMAIN -d $LOGNAME

Once you do all that, restart Postfix, and see if that works for you.

-Eric

I updated main.cf with the three lines you posted above.

The following is the mail.log from sending an email to my inbox from an outside server (Yahoo):

Jul  6 16:06:45 zh postfix/smtpd[29777]: connect from nm3-vm6.bullet.mail.ne1.yahoo.com[98.138.91.96]
Jul  6 16:06:45 zh postfix/smtpd[29777]: C2764120C37: client=nm3-vm6.bullet.mail.ne1.yahoo.com[98.138.91.96]
Jul  6 16:06:45 zh postfix/cleanup[29847]: C2764120C37: message-id=<67771719.3124051.1436213204063.JavaMail.yahoo@mail.yahoo.com>
Jul  6 16:06:45 zh postfix/qmgr[29733]: C2764120C37: from=<hidden@yahoo.com>, size=4490, nrcpt=1 (queue active)
Jul  6 16:06:46 zh postfix/smtpd[29777]: disconnect from nm3-vm6.bullet.mail.ne1.yahoo.com[98.138.91.96]
Jul  6 16:06:49 zh postfix/smtp[29848]: C2764120C37: to=<test@com.com>, orig_to=<test@myexampledomain.com>, relay=mail.mailerhost.net[54.243.118.246]:25, delay=3.4, delays=0.23/0/3.1/0.06, dsn=2.0.0, status=sent (250 OK (5A34710B-BF11-414E-B2D2-58005BB5AC2F.1))
Jul  6 16:06:49 zh postfix/qmgr[29733]: C2764120C37: removed

When trying to send an email from my server in mail.log I’m now getting:

Jul  6 16:08:44 zh postfix/smtpd[30064]: connect from localhost[127.0.0.1]
Jul  6 16:08:44 zh postfix/smtpd[30064]: warning: SASL authentication failure: unable to canonify user and get auxprops
Jul  6 16:08:44 zh postfix/smtpd[30064]: warning: localhost[127.0.0.1]: SASL DIGEST-MD5 authentication failed: authentication failure
Jul  6 16:08:44 zh postfix/smtpd[30064]: disconnect from localhost[127.0.0.1]

Roundcube now gives the following:

SMTP Error (535): Authentication failed. .

Thank you once again for your input, I feel like the problem is almost solved.

This may be important as well:
When sending to my main domain (let’s call it main.com) I get:

postfix/trivial-rewrite[4987]: warning: do not list domain main.com in BOTH mydestination and virtual_alias_domains

Hi Eric,

Are you still able to help out? I’m a Software Engineer but I’m totally clueless on this one. My virtualmin is totally funky right now. Even when viewing my Users within Virtualmin the “Primary email address enabled?” option won’t let me set it to yet. It keeps resetting to “no”.

Please help