haraka / Haraka

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

Bounce hook is not working when smtp_forward plugin is enabled #1336

Closed lakkisinghal closed 8 years ago

lakkisinghal commented 8 years ago

Hi, when my forward plugin is disabled then my logs look like -

[PROTOCOL] [BB9DA2F5-DF2A-42AF-88F6-F0ECD43F3619.1.1] [outbound] S: 220 mx.google.com ESMTP p62si10260564iop.199 - gsmtp\r\n [PROTOCOL] [BB9DA2F5-DF2A-42AF-88F6-F0ECD43F3619.1.1] [outbound] C: EHLO bmrc.bookyourshow.org [PROTOCOL] [BB9DA2F5-DF2A-42AF-88F6-F0ECD43F3619.1.1] [outbound] S: 250-mx.google.com at your service, [103.194.43.36]\r\n [PROTOCOL] [BB9DA2F5-DF2A-42AF-88F6-F0ECD43F3619.1.1] [outbound] S: 250-SIZE 35882577\r\n [PROTOCOL] [BB9DA2F5-DF2A-42AF-88F6-F0ECD43F3619.1.1] [outbound] S: 250-8BITMIME\r\n [PROTOCOL] [BB9DA2F5-DF2A-42AF-88F6-F0ECD43F3619.1.1] [outbound] S: 250-STARTTLS\r\n [PROTOCOL] [BB9DA2F5-DF2A-42AF-88F6-F0ECD43F3619.1.1] [outbound] S: 250-ENHANCEDSTATUSCODES\r\n [PROTOCOL] [BB9DA2F5-DF2A-42AF-88F6-F0ECD43F3619.1.1] [outbound] S: 250-PIPELINING\r\n [PROTOCOL] [BB9DA2F5-DF2A-42AF-88F6-F0ECD43F3619.1.1] [outbound] S: 250-CHUNKING\r\n [PROTOCOL] [BB9DA2F5-DF2A-42AF-88F6-F0ECD43F3619.1.1] [outbound] S: 250 SMTPUTF8\r\n [PROTOCOL] [BB9DA2F5-DF2A-42AF-88F6-F0ECD43F3619.1.1] [outbound] C: MAIL FROM:info@optkart.com [PROTOCOL] [BB9DA2F5-DF2A-42AF-88F6-F0ECD43F3619.1.1] [outbound] S: 250 2.1.0 OK p62si10260564iop.199 - gsmtp\r\n [PROTOCOL] [BB9DA2F5-DF2A-42AF-88F6-F0ECD43F3619.1.1] [outbound] C: RCPT TO:jksaakiuoiTy@gmail.com [PROTOCOL] [BB9DA2F5-DF2A-42AF-88F6-F0ECD43F3619.1.1] [outbound] S: 550-5.1.1 The email account that you tried to reach does not exist. Please try\r\n [PROTOCOL] [BB9DA2F5-DF2A-42AF-88F6-F0ECD43F3619.1.1] [outbound] S: 550-5.1.1 double-checking the recipient's email address for typos or\r\n [PROTOCOL] [BB9DA2F5-DF2A-42AF-88F6-F0ECD43F3619.1.1] [outbound] S: 550-5.1.1 unnecessary spaces. Learn more at\r\n [PROTOCOL] [BB9DA2F5-DF2A-42AF-88F6-F0ECD43F3619.1.1] [outbound] S: 550 5.1.1 https://support.google.com/mail/answer/6596 p62si10260564iop.199 - gsmtp\r\n _[NOTICE] [BB9DA2F5-DF2A-42AF-88F6-F0ECD43F3619.1.1] [outbound] recipient jksaakiuoiTy@gmail.com rejected: 550 5.1.1 The email account that you tried to reach does not exist. Please try double-checking the recipient's email address for typos or unnecessary spaces. Learn more at https://support.google.com/mail/answer/6596 p62si10260564iop.199 - gsmtp [INFO] [BB9DA2F5-DF2A-42AF-88F6-F0ECD43F3619.1.1] [outbound] bouncing mail: Some recipients failed: jksaakiuoiTy@gmail.com [DEBUG] [BB9DA2F5-DF2A-42AF-88F6-F0ECD43F3619.1.1] [outbound] running bounce hooks [PROTOCOL] [BB9DA2F5-DF2A-42AF-88F6-F0ECD43F3619.1.1] [outbound] C: QUIT [INFO] [-] [core] [outbound] Sending email via params [INFO] [-] [core] [outbound] Created transaction: D8E40FD5-178E-41F1-9CA2-D003B91F2305 [INFO] [-] [core] [outbound] Processing domain: optkart.com [DEBUG] [D8E40FD5-178E-41F1-9CA2-D003B91F2305.1] [outbound] running send_email hooks [DEBUG] [D8E40FD5-178E-41F1-9CA2-D003B91F2305.1] [outbound] Sending mail: 1455166463714_0_32571_7814.info@risedeal.net [DEBUG] [D8E40FD5-178E-41F1-9CA2-D003B91F2305.1] [outbound] running get_mx hooks [INFO] [D8E40FD5-178E-41F1-9CA2-D003B91F2305.1] [outbound] Looking up A records for: us2.mx3.mailhostbox.com [INFO] [D8E40FD5-178E-41F1-9CA2-D003B91F2305.1] [outbound] Attempting to deliver to: 208.91.199.226:25 (0) (0) [PROTOCOL] [D8E40FD5-178E-41F1-9CA2-D003B91F2305.1] [outbound] S: 521-5.3.2 Service currently unavailable\r\n [PROTOCOL] [D8E40FD5-178E-41F1-9CA2-D003B91F2305.1] [outbound] S: 521 5.3.2 Please see http://support.mailhostbox.com/email-administrators-guide/error-codes for explanation of the problem.\r\n [PROTOCOL] [D8E40FD5-178E-41F1-9CA2-D003B91F2305.1] [outbound] C: QUIT [INFO] [D8E40FD5-178E-41F1-9CA2-D003B91F2305.1] [outbound] bouncing mail: 521 5.3.2 Service currently unavailable Please see http://support.mailhostbox.com/email-administrators-guide/error-codes for explanation of the problem. [DEBUG] [D8E40FD5-178E-41F1-9CA2-D003B91F2305.1] [outbound] running bounce hooks [ERROR] [D8E40FD5-178E-41F1-9CA2-D003B91F2305.1] [outbound] Double bounce: Mail was already a bounce _

Now i enabled my forward plugin and logs are like -

[PROTOCOL] [A0704EA4-CCA5-41A0-AA31-F13881DBF141.1.1] [outbound] S: 220 panel.optkart.com ESMTP Postfix\r\n [PROTOCOL] [A0704EA4-CCA5-41A0-AA31-F13881DBF141.1.1] [outbound] C: EHLO bmrc.bookyourshow.org [PROTOCOL] [A0704EA4-CCA5-41A0-AA31-F13881DBF141.1.1] [outbound] S: 250-panel.optkart.com\r\n [PROTOCOL] [A0704EA4-CCA5-41A0-AA31-F13881DBF141.1.1] [outbound] S: 250-PIPELINING\r\n [PROTOCOL] [A0704EA4-CCA5-41A0-AA31-F13881DBF141.1.1] [outbound] S: 250-SIZE 10240000\r\n [PROTOCOL] [A0704EA4-CCA5-41A0-AA31-F13881DBF141.1.1] [outbound] S: 250-VRFY\r\n [PROTOCOL] [A0704EA4-CCA5-41A0-AA31-F13881DBF141.1.1] [outbound] S: 250-ETRN\r\n [PROTOCOL] [A0704EA4-CCA5-41A0-AA31-F13881DBF141.1.1] [outbound] S: 250-AUTH PLAIN LOGIN\r\n [PROTOCOL] [A0704EA4-CCA5-41A0-AA31-F13881DBF141.1.1] [outbound] S: 250-AUTH=PLAIN LOGIN\r\n [PROTOCOL] [A0704EA4-CCA5-41A0-AA31-F13881DBF141.1.1] [outbound] S: 250-ENHANCEDSTATUSCODES\r\n [PROTOCOL] [A0704EA4-CCA5-41A0-AA31-F13881DBF141.1.1] [outbound] S: 250-8BITMIME\r\n [PROTOCOL] [A0704EA4-CCA5-41A0-AA31-F13881DBF141.1.1] [outbound] S: 250 DSN\r\n [PROTOCOL] [A0704EA4-CCA5-41A0-AA31-F13881DBF141.1.1] [outbound] C: AUTH PLAIN bGFra2kAbGFra2kAbGFra2k= [PROTOCOL] [A0704EA4-CCA5-41A0-AA31-F13881DBF141.1.1] [outbound] S: 235 2.7.0 Authentication successful\r\n [PROTOCOL] [A0704EA4-CCA5-41A0-AA31-F13881DBF141.1.1] [outbound] C: MAIL FROM:info@optkart.com [PROTOCOL] [A0704EA4-CCA5-41A0-AA31-F13881DBF141.1.1] [outbound] S: 250 2.1.0 Ok\r\n [PROTOCOL] [A0704EA4-CCA5-41A0-AA31-F13881DBF141.1.1] [outbound] C: RCPT TO:jksaakiuoiTy@gmail.com [PROTOCOL] [A0704EA4-CCA5-41A0-AA31-F13881DBF141.1.1] [outbound] S: 250 2.1.5 Ok\r\n [PROTOCOL] [A0704EA4-CCA5-41A0-AA31-F13881DBF141.1.1] [outbound] C: DATA [PROTOCOL] [A0704EA4-CCA5-41A0-AA31-F13881DBF141.1.1] [outbound] S: 354 End data with .\r\n [PROTOCOL] [A0704EA4-CCA5-41A0-AA31-F13881DBF141.1.1] [outbound] C: . [PROTOCOL] [A0704EA4-CCA5-41A0-AA31-F13881DBF141.1.1] [outbound] S: 250 2.0.0 Ok: queued as D3E7B27FE4\r\n [NOTICE] [A0704EA4-CCA5-41A0-AA31-F13881DBF141.1.1] [outbound] delivered file=1455166523112_0_32582_441.info@risedeal.net domain="gmail.com" host="5.9.202.95" ip=5.9.202.95 port=587 mode=SMTP tls=N auth=Y response="Ok: queued as D3E7B27FE4" delay=2.668 fails=0 rcpts=1/0/0 [DEBUG] [A0704EA4-CCA5-41A0-AA31-F13881DBF141.1.1] [outbound] running delivered hooks [PROTOCOL] [A0704EA4-CCA5-41A0-AA31-F13881DBF141.1.1] [outbound] C: QUIT

For same RCPT two different logs are here. bounce hook is not giving proper response as i enabled forward plugin.

My smtp_forward.js - http://pastebin.com/nn2YTxJr Any idea where i am wrong?

smfreegard commented 8 years ago

Pretty simple really if you actually look closely at the log output.

Without your smtp_forward plugin, Haraka talks directly to the MX host (e.g. Google) and therefore when Google rejects the recipient or message - Haraka has to bounce the message back to the sender and therefore runs the bounce hooks.

Your SMTP forward plugin overrides the MX and pushes all mail to a single smart host which relays the message instead, not Haraka. In that case - the host you're sending all the mail to will always accept the message, queue it and then it will attempt to deliver it. If it bounces, then it will generate a bounce message back to the sender, so Haraka isn't involved in the process at all, so no bounce hooks are run.

lakkisinghal commented 8 years ago

smfreegard, but i want real logs and i don't want to relay all emails via only haraka ip. i want to relay emails via different nodes through haraka server but i think haraka main server will consider it only as queued and cosider all emails as delivered. i have tried proxy plugin also. Is there any way that first haraka check that if reciepient exist and yes then it relay email via different host using proxy plugin?

smfreegard commented 8 years ago

Is there any way that first haraka check that if reciepient exist

Sure - if you write some code verify the recipients first. But that won't cover the case where the recipient(s) are accepted but the message is rejected.

This is all specific to your use case. It's not a Haraka problem - it's doing exactly what it should be doing.