# Can't send email to users in my domain



## xy16644 (May 4, 2014)

When I try to send an email from user1@mydomain.com to user2@mydomain.com I get the following error in /var/log/maillog:


```
postfix/lmtp[62062]: 89306945: to=<user1@mydomain.com>, relay=mail.mydomain.com[private/dovecot-lmtp] said: 550 5.1.1 <user1@mydomain.com> User doesn't exist: user1@mydomain.com (in reply to RCPT TO command))
```

I use virtual users. Sending email to external domains works fine.

Today I changed the way logins work so that I can use "Application Specific Passwords". I changed my password query from:



```
password_query = SELECT email as user, password FROM virtual_users WHERE email='%u';
```

to:


```
password_query = SELECT NULL AS password,'Y' as nopassword, username AS user FROM mailserver.dovecot_passwords WHERE username = '%u' AND password=MD5(REPLACE('%w',' ',''))
```

Logging in works fine but I just can't figure out why I can't send emails to other users for domains that are hosted on my server. Any ideas?

My virtual domains, alises and users are all in a MySQL database.


----------

