Aliases not working - mysql

I'm trying to setup a mailserver with postfix and dovecot, however I can't get aliases to work for some reason. Everytime I send a mail to an alias I get "User unknown" or "User unknown in virtual mailbox table". I've used postmap -q alias#example.com mysql:/etc/postfix/mysql-virtual-alias-maps.cfand it returns user#example.com as expected. I've also enabled query logging in mysql and I can see the queries are executed, but for some reason it still checks if the user alias#example.com exists, which of course it doesn't.
main.cf:
myhostname = xx
smtpd_banner = \$myhostname ESMTP
biff = no
append_dot_mydomain = no
readme_directory = /usr/share/doc/postfix
smtpd_tls_cert_file = /etc/ssl/certs/xx.pem
smtpd_tls_key_file = /etc/ssl/private/xx.key
smtpd_use_tls = yes
smtpd_tls_session_cache_database = btree:${data_directory}/smtpd_scache
smtp_tls_session_cache_database = btree:${data_directory}/smtp_scache
alias_maps = hash:/etc/aliases
alias_database = hash:/etc/aliases
myorigin = /etc/mailname
mydestination =
relayhost =
mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128
mailbox_size_limit = 0
recipient_delimiter = +
inet_interfaces = all
html_directory = /usr/share/doc/postfix/html
inet_protocols = ipv4
virtual_transport = dovecot
virtual_mailbox_domains = mysql:/etc/postfix/mysql-virtual-mailbox-domains.cf
virtual_mailbox_maps = mysql:/etc/postfix/mysql-virtual-mailbox-maps.cf
virtual_alias_maps = mysql:/etc/postfix/mysql-virtual-alias-maps.cf
virtual_minimum_uid = 100
virtual_uid_maps = static:5000
virtual_gid_maps = static:5000
smtpd_helo_restrictions = reject_unknown_helo_hostname
smtpd_sender_restrictions = reject_unknown_sender_domain
smtpd_recipient_restrictions = permit_mynetworks, permit_sasl_authenticated, reject_unauth_destination, reject_rbl_client zen.spamhaus.org, reject_rhsbl_reverse_client dbl.spamhaus.org, reject_rhsbl_helo dbl.spamhaus.org, reject_rhsbl_sender dbl.spamhaus.org
smtpd_data_restrictions = reject_unauth_pipelining
smtpd_sasl_type = dovecot
smtpd_sasl_path = private/auth
smtpd_sasl_auth_enable = yes
smtpd_sasl_security_options = noanonymous
dovecot_destination_recipient_limit = 1
receive_override_options = no_address_mappings
milter_connect_macros = j {daemon_name} v {if_name} _
milter_default_action = accept
milter_protocol = 2
smtpd_milters = unix:/spamass/spamass.sock, unix:/clamav/clamav-milter.ctl, inet:localhost:12301
non_smtpd_milters = unix:/spamass/spamass.sock, unix:/clamav/clamav-milter.ctl, inet:localhost:12301
mysql-virtual-alias-maps.cf:
user = mailcp
password = xx
hosts = 127.0.0.1
dbname = mailcp
query = SELECT CONCAT(user_alias.name, '#', domain.name) as destination FROM user_alias INNER JOIN domain ON user_alias.domainID = domain.id WHERE user_alias.primary = 1 AND user_alias.userID IN (SELECT user_alias.userID FROM user_alias INNER JOIN domain ON user_alias.domainID = domain.id WHERE CONCAT(user_alias.name, '#', domain.name)='%s');
mysql-virtual-mailbox-domains.cf:
user = mailcp
password = xx
hosts = 127.0.0.1
dbname = mailcp
query = SELECT 1 FROM domain WHERE name='%s';
mysql-virtual-mailbox-maps.cf:
user = mailcp
password = xx
hosts = 127.0.0.1
dbname = mailcp
query = SELECT 1 FROM user_alias INNER JOIN domain ON user_alias.domainID = domain.id WHERE user_alias.primary = 1 AND CONCAT(user_alias.name, '#', domain.name)='%s';
dovecot-sql.conf.ext:
driver = mysql
connect = host=127.0.0.1 dbname=databasename user=username password=changepwd
default_pass_scheme = SHA512-CRYPT
password_query = SELECT CONCAT(user_alias.name, '#', domain.name) as user, user.password as password, concat('*:bytes=', (CASE WHEN user.quota -1 THEN user.quota ELSE domain.quota END)*1000000) AS userdb_quota_rule FROM user INNER JOIN user_alias ON user.id = user_alias.userID AND user_alias.primary = 1 INNER JOIN domain ON user_alias.domainID = domain.id WHERE CONCAT(user_alias.name, '#', domain.name) ='%u' AND user.status = 1
user_query = SELECT CONCAT('/var/mail/vmail/', domain.name, '/', user_alias.name) as home, 5000 AS uid, 5000 AS gid, concat('*:bytes=', (CASE WHEN user.quota != -1 THEN user.quota ELSE domain.quota END)*1000000) AS userdb_quota_rule FROM user INNER JOIN user_alias ON user.id = user_alias.userID AND user_alias.primary = 1 INNER JOIN domain ON user_alias.domainID = domain.id WHERE CONCAT(user_alias.name, '#', domain.name) ='%u' AND user.status = 1
mail.info (for one mail)
Oct 26 16:38:27 xx postfix/smtpd[538]: connect from mail-wg0-f51.google.com[74.125.82.51]
Oct 26 16:38:28 xx postfix/smtpd[538]: 1FD73580A0F: client=mail-wg0-f51.google.com[74.125.82.51]
Oct 26 16:38:28 xx postfix/cleanup[547]: 1FD73580A0F: message-id=<CAGPeO-YPiiA5TerbFqZ5j5t-PYtGuR2wSaKXUN1=ewTdO-0=Zw#mail.gmail.com>
Oct 26 16:38:28 xx spamd[29841]: spamd: connection from localhost.localdomain [127.0.0.1] at port 58956
Oct 26 16:38:28 xx spamd[29841]: spamd: processing message <CAGPeO-YPiiA5TerbFqZ5j5t-PYtGuR2wSaKXUN1=ewTdO-0=Zw#mail.gmail.com> for xx:1001
Oct 26 16:38:33 xx spamd[29841]: spamd: clean message (-0.7/5.0) for xx:1001 in 4.9 seconds, 1789 bytes.
Oct 26 16:38:33 xx spamd[29841]: spamd: result: . 0 - FREEMAIL_FROM,HTML_MESSAGE,RCVD_IN_DNSWL_LOW,SPF_PASS,T_DKIM_INVALID scantime=4.9,size=1789,user=xx,uid=1001,required_score=5.0,rhost=localhost.localdomain,raddr=127.0.0.1,rport=58956,mid=<CAGPeO-YPiiA5TerbFqZ5j5t-PYtGuR2wSaKXUN1=ewTdO-0=Zw#mail.gmail.com>,autolearn=ham
Oct 26 16:38:33 xx opendkim[25686]: 1FD73580A0F: mail-wg0-f51.google.com [74.125.82.51] not internal
Oct 26 16:38:33 xx opendkim[25686]: 1FD73580A0F: not authenticated
Oct 26 16:38:33 xx opendkim[25686]: 1FD73580A0F: DKIM verification successful
Oct 26 16:38:33 xx spamd[29840]: prefork: child states: II
Oct 26 16:38:33 xx postfix/qmgr[477]: 1FD73580A0F: from=<xx#gmail.com>, size=1749, nrcpt=1 (queue active)
Oct 26 16:38:33 xx dovecot: auth-worker(552): mysql(127.0.0.1): Connected to database mailcp
Oct 26 16:38:33 xx postfix/pipe[550]: 1FD73580A0F: to=<xx#xx.in>, relay=dovecot, delay=5.1, delays=5/0/0/0.03, dsn=5.1.1, status=bounced (user unknown)
Oct 26 16:38:33 xx postfix/cleanup[547]: 2012B580A53: message-id=<20141026153833.2012B580A53#xx.in>
Oct 26 16:38:33 xx postfix/bounce[554]: 1FD73580A0F: sender non-delivery notification: 2012B580A53
Oct 26 16:38:33 xx postfix/qmgr[477]: 2012B580A53: from=<>, size=3908, nrcpt=1 (queue active)
Oct 26 16:38:33 xx postfix/qmgr[477]: 1FD73580A0F: removed
Oct 26 16:38:33 xx postfix/smtpd[538]: disconnect from mail-wg0-f51.google.com[74.125.82.51]
Oct 26 16:38:33 xx postfix/smtp[556]: 2012B580A53: to=<xx#gmail.com>, relay=gmail-smtp-in.l.google.com[74.125.195.27]:25, delay=0.2, delays=0/0/0.09/0.1, dsn=2.0.0, status=sent (250 2.0.0 OK 1414337913 dk6si7742912wib.44 - gsmtp)
Oct 26 16:38:33 xx postfix/qmgr[477]: 2012B580A53: removed

Found the solution, apparently receive_override_options = no_address_mappings disables virtual aliases, so when I removed the line everything started to work as expected.

Related

Postfix - Rate limit for all domains

My client is a travel agency and has thousands of opted-in emails (no spam). Every week they send a message to all customers once, but I'm having problems with some providers and want to rate limit the entire server, for all outgoing domains.
I found some configurations to limit one message per domain per minute. I know how to create extra configuration (using transport file), to increase the numbers for some domains.
For some reason, Postfix is not rate-limiting anything :(
smtp_destination_rate_delay = 60s
default_destination_concurrency_limit = 1
smtp_destination_concurrency_limit = 1
smtp_destination_recipient_limit = 1
smtp_initial_destination_concurrency = 1
/etc/postfix/transport is empty
For example, for Hotmail, sending several messages in the same minute:
Jun 21 09:08:16 deres postfix/smtp[9905]: ABFB92165: to=<x#hotmail.com>, relay=hotmail-com.olc.protection.outlook.com[104.47.32.33]:25, delay=14, delays=11/0/0.83/1.4, dsn=2.6.0, status=sent (250 2.6.0 <600ef56d-18e7-4c10-9c7b-d0e5267c5589#SN1NAM01FT007.eop-nam01.prod.protection.outlook.com> [InternalId=9380208589439, Hostname=SN1NAM01HT004.eop-nam01.prod.protection.outlook.com] 442267 bytes in 1.070, 403.463 KB/sec Queued mail for delivery)
Jun 21 09:08:17 deres postfix/smtp[9849]: 59A7E2296: to=<y#hotmail.com>, relay=hotmail-com.olc.protection.outlook.com[104.47.32.33]:25, delay=14, delays=12/0/0.91/1.3, dsn=2.6.0, status=sent (250 2.6.0 <b6edd8d6-1302-45e9-8eef-a80b1d2659cd#SN1NAM01FT054.eop-nam01.prod.protection.outlook.com> [InternalId=9882719764030, Hostname=SN1NAM01HT090.eop-nam01.prod.protection.outlook.com] 442313 bytes in 0.689, 626.054 KB/sec Queued mail for delivery)
Jun 21 09:08:18 deres postfix/smtp[9836]: 0D0C122E7: to=<z#hotmail.com>, relay=hotmail-com.olc.protection.outlook.com[104.47.32.33]:25, delay=14, delays=12/0/0.76/1.5, dsn=2.6.0, status=sent (250 2.6.0 <8bd2a3d4-d20b-44f0-a90e-fc060b83380b#SN1NAM01FT014.eop-nam01.prod.protection.outlook.com> [InternalId=9354438785755, Hostname=SN1NAM01HT074.eop-nam01.prod.protection.outlook.com] 442283 bytes in 1.031, 418.834 KB/sec Queued mail for delivery)
The only thing (that I don't believe can impact) is that the customer sends the messages using an alternate port (5544 instead of 25/465/587).
Any ideia? Thank you.
Edit: as requested, my config.
alias_database = hash:/etc/aliases
alias_maps = hash:/etc/aliases
bounce_queue_lifetime = 1h
broken_sasl_auth_clients = yes
command_directory = /usr/sbin
config_directory = /etc/postfix
daemon_directory = /usr/libexec/postfix
debug_peer_level = 2
debugger_command = PATH=/bin:/usr/bin:/usr/local/bin:/usr/X11R6/bin xxgdb $daemon_directory/$process_name $process_id & sleep 5
default_destination_concurrency_limit = 1
delay_warning_time = 4
disable_vrfy_command = yes
dovecot_destination_recipient_limit = 1
html_directory = no
inet_interfaces = all
inet_protocols = all
mail_owner = postfix
mailq_path = /usr/bin/mailq.postfix
manpage_directory = /usr/share/man
maximal_backoff_time = 40m
maximal_queue_lifetime = 24h
message_size_limit = 26214400
minimal_backoff_time = 15m
mydestination = localhost.$mydomain, localhost
mydomain = deres.domain.com.br
myhostname = deres.domain.com.br
mynetworks = all
newaliases_path = /usr/bin/newaliases.postfix
queue_directory = /var/spool/postfix
queue_run_delay = 15m
readme_directory = /usr/share/doc/postfix-2.2.2/README_FILES
recipient_delimiter = +
relay_domains = proxy:mysql:/etc/sentora/configs/postfix/mysql-relay_domains_maps.cf
sample_directory = /usr/share/doc/postfix-2.2.2/samples
sendmail_path = /usr/sbin/sendmail.postfix
setgid_group = postdrop
smtp_defer_if_no_mx_address_found = no
smtp_destination_concurrency_limit = 1
smtp_destination_rate_delay = 55s
smtp_destination_recipient_limit = 1
smtp_initial_destination_concurrency = 1
smtp_tls_note_starttls_offer = yes
smtp_tls_session_cache_database = btree:$data_directory/smtp_tls_session_cache
smtp_use_tls = yes
smtpd_client_restrictions =
smtpd_data_restrictions = reject_unauth_pipelining,permit_sasl_authenticated
smtpd_discard_ehlo_keywords = silent-discard,dsn
smtpd_helo_required = yes
smtpd_helo_restrictions =
smtpd_recipient_restrictions = permit_sasl_authenticated, permit_mynetworks, reject_unauth_destination, reject_non_fqdn_sender, reject_non_fqdn_recipient, reject_unknown_recipient_domain ,reject_rbl_client zen.spamhaus.org ,reject_rbl_client bl.spamcop.net ,reject_rbl_client b.barracudacentral.org
smtpd_sasl_auth_enable = yes
smtpd_sasl_local_domain = $myhostname
smtpd_sasl_path = private/auth
smtpd_sasl_security_options = noanonymous
smtpd_sasl_type = dovecot
smtpd_sender_restrictions =
smtpd_tls_CAfile = /etc/letsencrypt/live/ca.pem
smtpd_tls_auth_only = no
smtpd_tls_cert_file = /etc/letsencrypt/live/...removed
smtpd_tls_key_file = /etc/letsencrypt/live/...removed
smtpd_tls_loglevel = 1
smtpd_tls_received_header = yes
smtpd_tls_security_level = may
smtpd_tls_session_cache_timeout = 3600s
smtpd_use_tls = yes
soft_bounce = no
tls_random_source = dev:/dev/urandom
transport_maps = hash:/etc/postfix/transport
unknown_address_reject_code = 554
unknown_hostname_reject_code = 554
unknown_local_recipient_reject_code = 550
virtual_alias_maps = proxy:mysql:/etc/sentora/configs/postfix/mysql-virtual_alias_maps.cf, regexp:/etc/sentora/configs/postfix/virtual_regexp
virtual_gid_maps = static:12
virtual_mailbox_base = /var/sentora/vmail
virtual_mailbox_domains = proxy:mysql:/etc/sentora/configs/postfix/mysql-virtual_domains_maps.cf
virtual_mailbox_maps = proxy:mysql:/etc/sentora/configs/postfix/mysql-virtual_mailbox_maps.cf
virtual_minimum_uid = 101
virtual_transport = dovecot
virtual_uid_maps = static:101
Solved.
Fixed with:
default_destination_recipient_limit = 2
smtp_destination_recipient_limit = 2
Sorry, I misread your question. You WANT rate limiting but don't seem to be getting it. Correct?
The settings you showed should work. Have you done a postfix reload? PF won't pick up changes in it's config file without a reload or restart.
If that doesn't do it, do a postconf -n, which will show the settings that it thinks you have in your config file, and post it here.
If what it thinks you set and what you actually set are different, you'll need to do some detective work to see where it's getting settings from.

Error when connecting Cygnus and STH

I am trying to connect Cygnus and STH. I have a Cygnus instance in a container docker and a STH instance in a VM.
When I send a notification to Cygnus, available at fiware-cygnus/cygnus-ngsi/resources/ngsi-examples/notification-json-simple.sh it shows me the following error:
NOTE: I replaced the STH IP to post the question
time=2017-03-06T17:35:46.522Z | lvl=ERROR | corr=0767a9d2-d44e-4872-9ef4-b57d68ef7f88 | trans=0767a9d2-d44e-4872-9ef4-b57d68ef7f88 | srv=red | subsrv=/red/red | comp=cygnus-ngsi | op=processRollbackedBatches | msg=com.telefonica.iot.cygnus.sinks.NGSISink[394] : Persistence error. Message: -, Timed out after 30000 ms while waiting for a server that matches PrimaryServerSelector. Client view of cluster state is {type=UNKNOWN, servers=[{address=:27017, type=UNKNOWN, state=CONNECTING, exception={com.mongodb.MongoSocketReadException: Exception receiving message}, caused by {java.net.SocketException: Connection reset}}], Stack trace: [com.telefonica.iot.cygnus.sinks.NGSISTHSink.persistOne(NGSISTHSink.java:158), com.telefonica.iot.cygnus.sinks.NGSISTHSink.persistBatch(NGSISTHSink.java:93), com.telefonica.iot.cygnus.sinks.NGSISink.processRollbackedBatches(NGSISink.java:387), com.telefonica.iot.cygnus.sinks.NGSISink.process(NGSISink.java:370), org.apache.flume.sink.DefaultSinkProcessor.process(DefaultSinkProcessor.java:68), org.apache.flume.SinkRunner$PollingRunner.run(SinkRunner.java:147), java.lang.Thread.run(Thread.java:745)]
time=2017-03-06T17:35:46.522Z | lvl=INFO | corr=0767a9d2-d44e-4872-9ef4-b57d68ef7f88 | trans=0767a9d2-d44e-4872-9ef4-b57d68ef7f88 | srv=red | subsrv=/red/red | comp=cygnus-ngsi | op=doRollbackAgain | msg=com.telefonica.iot.cygnus.sinks.NGSISink[458] : Rollbacking again (0767a9d2-d44e-4872-9ef4-b57d68ef7f88), this was retry #9
And nothing is posted in STH.
In my agent.conf (cygnus conf) I have this:
cygnus-ngsi.sources = http-source
cygnus-ngsi.sinks = sth-sink
cygnus-ngsi.channels = sth-channel
cygnus-ngsi.sources.http-source.type = org.apache.flume.source.http.HTTPSource
cygnus-ngsi.sources.http-source.channels = sth-channel
cygnus-ngsi.sources.http-source.port = 5050
cygnus-ngsi.sources.http-source.handler = com.telefonica.iot.cygnus.handlers.NGSIRestHandler
cygnus-ngsi.sources.http-source.handler.notification_target = /notify
cygnus-ngsi.sources.http-source.handler.default_service = default
cygnus-ngsi.sources.http-source.handler.default_service_path = /
cygnus-ngsi.sources.http-source.interceptors = ts gi
cygnus-ngsi.sources.http-source.interceptors.ts.type = timestamp
cygnus-ngsi.sources.http-source.interceptors.gi.type = com.telefonica.iot.cygnus.interceptors.NGSIGroupingInterceptor$Builder
cygnus-ngsi.sources.http-source.interceptors.gi.grouping_rules_conf_file = /opt/apache-flume/conf/grouping_rules.conf
cygnus-ngsi.sinks.sth-sink.type = com.telefonica.iot.cygnus.sinks.NGSISTHSink
cygnus-ngsi.sinks.sth-sink.channel = sth-channel
#cygnus-ngsi.sinks.sth-sink.enable_encoding = false
#cygnus-ngsi.sinks.sth-sink.enable_grouping = false
#cygnus-ngsi.sinks.sth-sink.enable_name_mappings = false
#cygnus-ngsi.sinks.sth-sink.enable_lowercase = false
cygnus-ngsi.sinks.sth-sink.data_model = dm-by-entity
cygnus-ngsi.sinks.sth-sink.mongo_hosts = <STH-MONGO-IP>:27017
cygnus-ngsi.sinks.sth-sink.mongo_username =
cygnus-ngsi.sinks.sth-sink.mongo_password =
cygnus-ngsi.sinks.sth-sink.db_prefix = sth_
cygnus-ngsi.sinks.sth-sink.collection_prefix = sth_
cygnus-ngsi.sinks.sth-sink.resolutions = day,hour,minute
#cygnus-ngsi.sinks.sth-sink.batch_size = 1
#cygnus-ngsi.sinks.sth-sink.batch_timeout = 30
#cygnus-ngsi.sinks.sth-sink.batch_ttl = 10
#cygnus-ngsi.sinks.sth-sink.data_expiration = 0
#cygnus-ngsi.sinks.sth-sink.ignore_white_spaces = true
cygnus-ngsi.channels.sth-channel.type = com.telefonica.iot.cygnus.channels.CygnusMemoryChannel
cygnus-ngsi.channels.sth-channel.capacity = 1000
cygnus-ngsi.channels.sth-channel.transactionCapacity = 100
And my STH config is:
var config = {};
// STH server configuration
//--------------------------
config.server = {
host: '10.0.2.15',
port: '8666',
defaultService: 'testservice',
defaultServicePath: '/testservicepath',
filterOutEmpty: 'true',
aggregationBy: ['day', 'hour', 'minute'],
temporalDir: 'temp'
};
// Database configuration
//------------------------
config.database = {
dataModel: 'collection-per-entity',
user: '',
password: '',
URI: 'localhost:27017',
replicaSet: '',
prefix: 'sth_',
collectionPrefix: 'sth_',
poolSize: '5',
shouldStore: 'both',
truncation: {
expireAfterSeconds: '0',
size: '0',
max: '0'
},
ignoreBlankSpaces: 'true',
nameMapping: {
enabled: 'false',
configFile: './name-mapping.json'
},
nameEncoding: 'false'
};
// Logging configuration
//------------------------
config.logging = {
level: 'info',
NODE_ENV variable is set to 'development'.
format: 'pipe',
proofOfLifeInterval: '60'
};
module.exports = config;
I found the solution for this problem: I just edited my /etc/mongod.conf and I commented out the bindip=127.0.0.1 to listen on all interfaces.

Remote enable xdebug in PHPStorm for console scripts

How can I use xdebug on console scripts with PHPStorm 9 without having to enable xdebug.remote_autostart?
I've found that if I have xdebug.remote_autostart enabled, it hangs certain console scripts trying to do a DNS lookup.
I'm connecting to a vagrant box.
Here is my current Xdebug config:
zend_extension = xdebug.so
xdebug.var_display_max_data = -1
xdebug.var_display_max_depth = 10
xdebug.default_enable = 0
xdebug.remote_enable = 1
xdebug.remote_connect_back = 1
xdebug.remote_port = 9001
xdebug.remote_host = 192.168.10.1
xdebug.remote_autostart = 0
xdebug.remote_handler = dbgp
xdebug.idekey = PHPSTORM
xdebug.collect_return = 1
xdebug.collect_params = 10
xdebug.show_mem_delta = 1
xdebug.profiler_enable_trigger = 1
xdebug.profiler_output_dir = "/home/vagrant/Projects/xdebug_profiler"
xdebug.trace_enable_trigger = 1
xdebug.trace_output_dir = "/home/vagrant/Projects/xdebug_traces"
xdebug.profiler_enable = 0
xdebug.trace_enable = 1

Postfix mysql different schemas and test user

I am trying to setup postfix mail server using ansible playbook. I am puzzled to understand different ways to setup postfix with mysql. I am not able to hold on to a complete schema. The one I got here and here
are some examples.
Using the schema from ansible role above I have setup postfix. And the schema tables include:
show tables;
+-------------------+
| Tables_in_mail |
+-------------------+
| alias |
| alias_destination |
| domain |
| domain_users |
| mailbox |
| mailbox_usage |
| user |
+-------------------+
7 rows in set (0.00 sec)
Now I want to test the postfix server with a test user /mailbox and domain.So I am looking for a way to init the schema for a test user. Any kind of help is appreciated
Edit
Tried to add a test user:
mysql> select * from user;
+----+-----------+---------------+--------+-------------+---------------------+---------------------+
| id | username | password | active | super_admin | created_at | modified_at |
+----+-----------+---------------+--------+-------------+---------------------+---------------------+
| 1 | sakhunzai | dTzdFMm0DSvmM | 1 | 0 | 0000-00-00 00:00:00 | 0000-00-00 00:00:00 |
+----+-----------+---------------+--------+-------------+---------------------+---------------------+
1 row in set (0.00 sec)
mysql> select * from domain;
+-------------+--------+-----------+-----------------------+---------------------+---------------------+
| name | active | backup_mx | default_mailbox_quota | created_at | modified_at |
+-------------+--------+-----------+-----------------------+---------------------+---------------------+
| example.com | 1 | 0 | 1073741824 | 0000-00-00 00:00:00 | 0000-00-00 00:00:00 |
+-------------+--------+-----------+-----------------------+---------------------+---------------------+
1 row in set (0.00 sec)
mysql> select * from mailbox;
+-----------+-------------+------------+------+--------+--------------+----------------+---------------------+---------------------+---------------+
| username | domain | local_part | name | active | quota_mbytes | quota_messages | created_at | modified_at | password |
+-----------+-------------+------------+------+--------+--------------+----------------+---------------------+---------------------+---------------+
| sakhunzai | example.com | | NULL | 1 | 0 | 0 | 0000-00-00 00:00:00 | 0000-00-00 00:00:00 | wZQ9cRLxshVEY |
+-----------+-------------+------------+------+--------+--------------+----------------+---------------------+---------------------+---------------+
1 row in set (0.00 sec)
Testing from telnet:
telnet mail.example.com 25
Trying 127.0.1.1...
Connected to mail.example.com.
Escape character is '^]'.
220 mail.example.com ESMTP Postfix
HELO test.example.com
250 mail.example.com
MAIL FROM: <sakhunzai#example.com>
250 2.1.0 Ok
RCPT TO:<sakhunzai#example.com>
550 5.1.1 <sakhunzai#example.com>: Recipient address rejected: User unknown in virtual mailbox table
Edit 2
After updating username I am able to complete the test:
update user set username="sakhunzai#example.com";
update mailbox set username="sakhunzai#example.com";
telnet mail.example.com 25
Trying 127.0.1.1...
Connected to mail.example.com.
Escape character is '^]'.
220 mail.example.com ESMTP Postfix
HELO test.example.com
250 mail.example.com
MAIL FROM: <sakhunzai#example.com>
250 2.1.0 Ok
RCPT TO:<sakhunzai#example.com>
250 2.1.5 Ok
DATA
354 End data with <CR><LF>.<CR><LF>
Subject: test message
.
250 2.0.0 Ok: queued as 3BEEB40940
QUIT
221 2.0.0 Bye
Connection closed by foreign host.
But with some errors in mail.log file:
to=<sakhunzai#example.com>, relay=none, delay=44, delays=44/0/0/0, dsn=4.3.0, status=deferred (mail transport unavailable)
Nov 10 08:13:51 postfix/smtpd[32013]: connect from localhost[127.0.0.1]
Nov 10 08:14:09 postfix/smtpd[32013]: 3BEEB40940: client=localhost[127.0.0.1]
Nov 10 08:14:49 postfix/cleanup[32020]: 3BEEB40940: message-id=<20151110081409.3BEEB40940#mail.example.com>
Nov 10 08:14:49 postfix/qmgr[8096]: 3BEEB40940: from=<sakhunzai#example.com>, size=337, nrcpt=1 (queue active)
Nov 10 08:14:49 postfix/qmgr[8096]: warning: connect to transport private/smtp-amavis: No such file or directory
Nov 10 08:14:49 postfix/error[32021]: 3BEEB40940: to=<sakhunzai#example.com>, relay=none, delay=44, delays=44/0/0/0, dsn=4.3.0, status=deferred (mail transport unavailable)
Nov 10 08:14:56 postfix/smtpd[32013]: disconnect from localhost[127.0.0.1]
postconf -n
alias_database = hash:/etc/aliases
alias_maps = hash:/etc/aliases
append_dot_mydomain = no
biff = no
broken_sasl_auth_clients = yes
config_directory = /etc/postfix
content_filter = smtp-amavis:[127.0.0.1]:10024
delay_warning_time = 4h
dovecot_destination_recipient_limit = 1
inet_interfaces = all
inet_protocols = all
mailbox_size_limit = 0
message_size_limit = 51200000
mime_header_checks = regexp:/etc/postfix/mime_header_checks.regexp
mydestination =
myhostname = mail.example.com
mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128
myorigin = /etc/mailname
queue_directory = /var/spool/postfix
readme_directory = no
recipient_delimiter = +
relay_domains = proxy:mysql:/etc/postfix/mysql_relay_domains_maps.cf
relayhost =
smtp_header_checks = pcre:/etc/postfix/smtp_header_checks.pcre
smtp_tls_security_level = may
smtp_tls_session_cache_database = btree:${data_directory}/smtp_scache
smtpd_banner = $myhostname ESMTP $mail_name
smtpd_client_restrictions =
smtpd_helo_restrictions =
smtpd_recipient_restrictions = reject_unauth_destination reject_unlisted_recipient reject_rbl_client zen.spamhaus.org permit
smtpd_sasl_auth_enable = yes
smtpd_sasl_authenticated_header = yes
smtpd_sasl_path = private/auth
smtpd_sasl_security_options = noanonymous
smtpd_sasl_type = dovecot
smtpd_sender_restrictions =
smtpd_tls_cert_file = /etc/ssl/private/mail.example.com.crt
smtpd_tls_key_file = /etc/ssl/private/mail.example.com.key
smtpd_tls_loglevel = 1
smtpd_tls_received_header = yes
smtpd_tls_security_level = may
smtpd_tls_session_cache_database = btree:${data_directory}/smtpd_scache
virtual_alias_maps = proxy:mysql:/etc/postfix/mysql_virtual_alias_mailbox_maps.cf proxy:mysql:/etc/postfix/mysql_virtual_alias_maps.cf
virtual_mailbox_domains = proxy:mysql:/etc/postfix/mysql_virtual_domains_maps.cf
virtual_mailbox_maps = proxy:mysql:/etc/postfix/mysql_virtual_mailbox_maps.cf
virtual_transport = dovecot
/etc/postfix/master.cf
#
# Postfix master process configuration file. For details on the format
# of the file, see the master(5) manual page (command: "man 5 master").
#
# Do not forget to execute "postfix reload" after editing this file.
#
# ==========================================================================
# service type private unpriv chroot wakeup maxproc command + args
# (yes) (yes) (yes) (never) (100)
# ==========================================================================
smtp inet n - - - - smtpd
#smtp inet n - - - 1 postscreen
#smtpd pass - - - - - smtpd
#dnsblog unix - - - - 0 dnsblog
#tlsproxy unix - - - - 0 tlsproxy
submission inet n - n - - smtpd
-o content_filter=smtp-amavis:[127.0.0.1]:10026
-o syslog_name=postfix/submission
-o smtpd_tls_security_level=encrypt
-o smtpd_sasl_auth_enable=yes
-o smtpd_recipient_restrictions=permit_sasl_authenticated,permit_mynetworks,reject
# -o milter_macro_daemon_name=ORIGINATING
#smtps inet n - - - - smtpd
# -o syslog_name=postfix/smtps
# -o smtpd_tls_wrappermode=yes
# -o smtpd_sasl_auth_enable=yes
# -o smtpd_client_restrictions=permit_sasl_authenticated,reject
# -o milter_macro_daemon_name=ORIGINATING
#628 inet n - - - - qmqpd
pickup fifo n - - 60 1 pickup
-o receive_override_options=no_header_body_checks
-o content_filter=smtp-amavis:[127.0.0.1]:10026
# Coment the above line if you do not want to sign localy originated mail from the pickup service
cleanup unix n - - - 0 cleanup
qmgr fifo n - n 300 1 qmgr
#qmgr fifo n - n 300 1 oqmgr
tlsmgr unix - - - 1000? 1 tlsmgr
rewrite unix - - - - - trivial-rewrite
bounce unix - - - - 0 bounce
defer unix - - - - 0 bounce
trace unix - - - - 0 bounce
verify unix - - - - 1 verify
flush unix n - - 1000? 0 flush
proxymap unix - - n - - proxymap
proxywrite unix - - n - 1 proxymap
smtp unix - - - - - smtp
relay unix - - - - - smtp
# -o smtp_helo_timeout=5 -o smtp_connect_timeout=5
showq unix n - - - - showq
error unix - - - - - error
retry unix - - - - - error
discard unix - - - - - discard
local unix - n n - - local
virtual unix - n n - - virtual
lmtp unix - - - - - lmtp
anvil unix - - - - 1 anvil
scache unix - - - - 1 scache
#
# ====================================================================
# Interfaces to non-Postfix software. Be sure to examine the manual
# pages of the non-Postfix software to find out what options it wants.
#
# Many of the following services use the Postfix pipe(8) delivery
# agent. See the pipe(8) man page for information about ${recipient}
# and other message envelope options.
# ====================================================================
#
# maildrop. See the Postfix MAILDROP_README file for details.
# Also specify in main.cf: maildrop_destination_recipient_limit=1
#
#maildrop unix - n n - - pipe
# flags=DRhu user=vmail argv=/usr/bin/maildrop -d ${recipient}
#
# ====================================================================
#
# Recent Cyrus versions can use the existing "lmtp" master.cf entry.
#
# Specify in cyrus.conf:
# lmtp cmd="lmtpd -a" listen="localhost:lmtp" proto=tcp4
#
# Specify in main.cf one or more of the following:
# mailbox_transport = lmtp:inet:localhost
# virtual_transport = lmtp:inet:localhost
#
# ====================================================================
#
# Cyrus 2.1.5 (Amos Gouaux)
# Also specify in main.cf: cyrus_destination_recipient_limit=1
#
#cyrus unix - n n - - pipe
# user=cyrus argv=/cyrus/bin/deliver -e -r ${sender} -m ${extension} ${user}
#
# ====================================================================
# Old example of delivery via Cyrus.
#
#old-cyrus unix - n n - - pipe
# flags=R user=cyrus argv=/cyrus/bin/deliver -e -m ${extension} ${user}
#
# ====================================================================
#
# See the Postfix UUCP_README file for configuration details.
#
#uucp unix - n n - - pipe
# flags=Fqhu user=uucp argv=uux -r -n -z -a$sender - $nexthop!rmail ($recipient)
#
# Other external delivery methods.
#
#ifmail unix - n n - - pipe
# flags=F user=ftn argv=/usr/lib/ifmail/ifmail -r $nexthop ($recipient)
#bsmtp unix - n n - - pipe
# flags=Fq. user=bsmtp argv=/usr/lib/bsmtp/bsmtp -t$nexthop -f$sender $recipient
#scalemail-backend unix - n n - 2 pipe
# flags=R user=scalemail argv=/usr/lib/scalemail/bin/scalemail-store ${nexthop} ${user} ${extension}
#mailman unix - n n - - pipe
# flags=FR user=list argv=/usr/lib/mailman/bin/postfix-to-mailman.py
# ${nexthop} ${user}
# Dovecot
dovecot unix - n n - - pipe
flags=DRhu user=vmail:vmail argv=/usr/lib/dovecot/dovecot-lda -f ${sender} -d ${user}#${domain} -m ${extension}
# Amavisd-new
smtp-amavis unix - - - - 2 smtp
-o smtp_data_done_timeout=1200
-o smtp_send_xforward_command=yes
-o disable_dns_lookups=yes
-o max_use=20
127.0.0.1:10025 inet n - - - - smtpd
-o content_filter=
-o local_recipient_maps=
-o relay_recipient_maps=
-o smtpd_restriction_classes=
-o smtpd_delay_reject=no
-o smtpd_client_restrictions=permit_mynetworks,reject
-o smtpd_helo_restrictions=
-o smtpd_sender_restrictions=
-o smtpd_recipient_restrictions=permit_mynetworks,reject
-o smtpd_data_restrictions=reject_unauth_pipelining
-o smtpd_end_of_data_restrictions=
-o mynetworks=127.0.0.0/8
-o smtpd_error_sleep_time=0
-o smtpd_soft_error_limit=1001
-o smtpd_hard_error_limit=1000
-o smtpd_client_connection_count_limit=0
-o smtpd_client_connection_rate_limit=0
-o receive_override_options=no_header_body_checks,no_unknown_recipient_checks,no_address_mappings
Based upon this and this similar issues:
Comment this line
-o content_filter=smtp-amavis:[127.0.0.1]:10026
and try

Sphinx Error: failed to merge index

While merging index with delta on Sphinx, I got this error:
~: /usr/local/bin/indexer --merge myindex myindexDelta --rotate;
Sphinx 2.0.6-release (r3473)
Copyright (c) 2001-2012, Andrew Aksyonoff
Copyright (c) 2008-2012, Sphinx Technologies Inc ( http://sphinxsearch.com )
using config file '/usr/local/etc/sphinx.conf'...
merging index 'myindexDelta' into index 'myindex'...
read 414.6 of 414.6 MB, 100.0% done
FATAL: failed to merge index 'myindexDelta' into index 'myindex': failed to open /server/sphinx/data/myindex.sps: No such file or directory
My configuration on sphinx.conf is as following
source myindex
{
type = mysql
sql_host = localhost
sql_user = db
sql_pass =
sql_db = db
sql_query_pre = SET SESSION query_cache_type=OFF
sql_query_pre = REPLACE INTO sph_counter SELECT 1, MAX(id) FROM mytable
sql_query_pre = SET NAMES utf8
sql_query = \
SELECT id,title FROM mytable \
WHERE id<=( SELECT max_doc_id FROM sph_counter WHERE counter_id=1 )
sql_ranged_throttle = 0
}
source myindexDelta : myindex
{
sql_query_pre = SET SESSION query_cache_type=OFF
sql_query_pre = SET NAMES utf8
sql_query = \
SELECT id,title FROM mytable \
WHERE id > ( SELECT max_doc_id FROM sph_counter WHERE counter_id=1 )
}
index myindex
{
source = myindex
path = /server/sphinx/data/myindex
min_word_len = 3
min_infix_len = 0
}
index myindexDelta : myindex
{
source = myindexDelta
path = /server/sphinx/data/myindexDelta
min_word_len = 3
min_infix_len = 0
}
indexes files listings with permissions:
~: ls -lh /server/sphinx/data/
-rw-r--r-- 1 root root 0 Nov 11 21:40 myindexDelta.spa
-rw-r--r-- 1 root root 290K Nov 11 21:40 myindexDelta.spd
-rw-r--r-- 1 root root 328 Nov 11 21:40 myindexDelta.sph
-rw-r--r-- 1 root root 106K Nov 11 21:40 myindexDelta.spi
-rw-r--r-- 1 root root 0 Nov 11 21:40 myindexDelta.spk
-rw------- 1 root root 0 Nov 11 21:40 myindexDelta.spl
-rw-r--r-- 1 root root 0 Nov 11 21:40 myindexDelta.spm
-rw-r--r-- 1 root root 223K Nov 11 21:40 myindexDelta.spp
-rw-r--r-- 1 root root 1 Nov 11 21:40 myindexDelta.sps
-rw-r--r-- 1 root root 0 Jul 3 21:17 myindex.spa
-rw-r--r-- 1 root root 7.0G Jul 3 23:54 myindex.spd
-rw-r--r-- 1 root root 290 Jul 3 23:54 myindex.sph
-rw-r--r-- 1 root root 397M Jul 3 23:54 myindex.spi
-rw-r--r-- 1 root root 0 Jul 3 23:54 myindex.spk
-rw------- 1 root root 0 Nov 11 21:08 myindex.spl
-rw-r--r-- 1 root root 0 Jul 3 21:17 myindex.spm
-rw-r--r-- 1 root root 9.2G Jul 3 23:54 myindex.spp
I am sure the code explains everything, adding description is not necessary.
I'm guessing that the original 'myindex' was made by a different version of sphinx. (ie dont think 2.0.6-release would of been available in July)
And somewhere in that version update, the requirement for a .sps file has changed - the new version requires it, whereas the old doesnt. You have no string attributes hence why the file contains no data in the delta.
I would suggest either rebuilding myindex with your current version of indexer - so they versions are identical.
Or maybe you could try copying myindexDelta.sps to myindex.sps. It contains no data (1 dummy byte!) so it shouldn't corrupt anything. Would only need to do this once.