haraka / Haraka

A fast, highly extensible, and event driven SMTP server
https://haraka.github.io
MIT License
5.02k stars 662 forks source link

Haraka inbound email error: 550 #643

Closed proxima-b-alpha closed 9 years ago

proxima-b-alpha commented 10 years ago

I have configured DNS and MX records correctly. I have tested with POSTFIX and DOVECOT and its working fine with inbound and outbound.

But when i try to accept inbound emails in Haraka i get below error: [core] S: 550 I cannot deliver mail for root@testhost_03.com

Please check the log data from Haraka below and also:

  1. How do i setup MySQL and/or MongoDB for virtual users and mailboxes with Haraka?
  2. Can you please link me to any tutorial that shows how to setup Haraka with Dovecot?

================ LOG =================

[NOTICE] [194A9B70-DD67-4954-8066-FE99D31875CF] [core] connect ip=192.168.91.129 port=44452 local_ip=:: local_port=25 [DEBUG] [194A9B70-DD67-4954-8066-FE99D31875CF] [core] running lookup_rdns hooks [DEBUG] [194A9B70-DD67-4954-8066-FE99D31875CF] [core] running connect hooks [PROTOCOL] [194A9B70-DD67-4954-8066-FE99D31875CF] [core] S: 220 testhost_03 ESMTP Haraka 2.5.0 ready [PROTOCOL] [194A9B70-DD67-4954-8066-FE99D31875CF] [core] C: EHLO testhost_01.com state=1 [DEBUG] [194A9B70-DD67-4954-8066-FE99D31875CF] [core] running ehlo hooks [DEBUG] [194A9B70-DD67-4954-8066-FE99D31875CF] [core] running capabilities hooks [DEBUG] [194A9B70-DD67-4954-8066-FE99D31875CF] [core] running capabilities hook in auth/flat_file plugin [DEBUG] [194A9B70-DD67-4954-8066-FE99D31875CF] [core] hook=capabilities plugin=auth/flat_file function=hook_capabilities params="" retval=CONT msg="" [PROTOCOL] [194A9B70-DD67-4954-8066-FE99D31875CF] [core] S: 250-testhost_03 Hello Unknown [192.168.91.129], Haraka is at your service. [PROTOCOL] [194A9B70-DD67-4954-8066-FE99D31875CF] [core] S: 250-PIPELINING [PROTOCOL] [194A9B70-DD67-4954-8066-FE99D31875CF] [core] S: 250-8BITMIME [PROTOCOL] [194A9B70-DD67-4954-8066-FE99D31875CF] [core] S: 250-SIZE 500000 [PROTOCOL] [194A9B70-DD67-4954-8066-FE99D31875CF] [core] S: 250 AUTH LOGIN CRAM-MD5 [PROTOCOL] [194A9B70-DD67-4954-8066-FE99D31875CF] [core] C: MAIL FROM:user2@testhost_02.com SIZE=585 state=1 [DEBUG] [194A9B70-DD67-4954-8066-FE99D31875CF.1] [core] running mail hooks [NOTICE] [194A9B70-DD67-4954-8066-FE99D31875CF.1] [core] sender user2@testhost_02.com code=CONT msg="" [PROTOCOL] [194A9B70-DD67-4954-8066-FE99D31875CF.1] [core] S: 250 sender user2@testhost_02.com OK [PROTOCOL] [194A9B70-DD67-4954-8066-FE99D31875CF.1] [core] C: RCPT TO:root@testhost_03.com state=1 [DEBUG] [194A9B70-DD67-4954-8066-FE99D31875CF.1] [core] running rcpt hooks [NOTICE] [194A9B70-DD67-4954-8066-FE99D31875CF.1] [core] recipient root@testhost_03.com code=CONT msg="" sender="user2@testhost_02.com" [PROTOCOL] [194A9B70-DD67-4954-8066-FE99D31875CF.1] [core] S: 550 I cannot deliver mail for root@testhost_03.com [PROTOCOL] [194A9B70-DD67-4954-8066-FE99D31875CF.1] [core] C: DATA state=1 [PROTOCOL] [194A9B70-DD67-4954-8066-FE99D31875CF.1] [core] S: 503 RCPT required first [PROTOCOL] [194A9B70-DD67-4954-8066-FE99D31875CF.1] [core] C: RSET state=1 [DEBUG] [194A9B70-DD67-4954-8066-FE99D31875CF.1] [core] running rset hooks [PROTOCOL] [194A9B70-DD67-4954-8066-FE99D31875CF.1] [core] S: 250 OK [DEBUG] [194A9B70-DD67-4954-8066-FE99D31875CF.1] [core] running reset_transaction hooks [PROTOCOL] [194A9B70-DD67-4954-8066-FE99D31875CF.1] [core] C: QUIT state=1 [DEBUG] [194A9B70-DD67-4954-8066-FE99D31875CF.1] [core] running quit hooks [PROTOCOL] [194A9B70-DD67-4954-8066-FE99D31875CF.1] [core] S: 221 testhost_03 closing connection. Have a jolly good day. [DEBUG] [194A9B70-DD67-4954-8066-FE99D31875CF.1] [core] running disconnect hooks [NOTICE] [194A9B70-DD67-4954-8066-FE99D31875CF.1] [core] disconnect ip=192.168.91.129 rdns="Unknown" helo="testhost_01.com" relay=N early=N esmtp=Y tls=N pipe=N txns=1 rcpts=0/0/1 msgs=0/0/0 bytes=0 lr="503 RCPT required first" time=0.207 ^C[NOTICE] [-] [core] SIGINT received [NOTICE] [-] [core] Shutting down

smfreegard commented 10 years ago

The key lines are these:

[NOTICE] [194A9B70-DD67-4954-8066-FE99D31875CF.1] [core] recipient root@testhost_03.com code=CONT msg="" sender="user2@testhost_02.com"
[PROTOCOL] [194A9B70-DD67-4954-8066-FE99D31875CF.1] [core] S: 550 I cannot deliver mail for root@testhost_03.com

Haraka needs to know which recipients, domains or hostnames should be allowed in (think of this like Postfix's local_recipient_map) and the way this works in Haraka is that at least one hook_rcpt plugin MUST return next(OK) to a recipient for Haraka to accept it. What is happening here is that you don't appear to have any rcpt hook plugins loaded, so it's falling through and returning the default '550 I cannot deliver mail for ...'.

What you probably need to do is load rcpt_to.in_host_list in config/plugins and add testhost_01.com to config/host_list for the recipient to be accepted. After that you will need another plugin that forces the routing for the domain to the appropriate Dovecot host using LMTP (this plugin doesn't currently exist - I've looked through the current plugins and the 'relay' plugin looks the easiest to modify for this purpose).

As for doing the routing using MongoDB or MySQL - we don't have any plugins written to do that, so you will need to write them yourself.

smfreegard commented 10 years ago

BTW: if you want to ask 'live' questions; then we're usually around on #Haraka on Freenode IRC.

smfreegard commented 10 years ago

Apologies; baudehlo just pointed out that I'd forgotten about the queue/lmtp plugin, so all you would need to do is enable the rcpt_to.in_host_list plugin and the queue/lmtp plugin and add your domains to config/host_list and config/lmtp.ini and it will route the messages correctly to Dovecot.

Once you have that working you can then decide how you want to modify that process to work via MongoDB or MySQL.