simple-login / app

The SimpleLogin back-end and web app
https://simplelogin.io
GNU Affero General Public License v3.0
5.13k stars 434 forks source link

self-hosted not able to send/receive email from aliases #1657

Open Syerween opened 1 year ago

Syerween commented 1 year ago

I did follow all the instructions but I am not able to send/receive email from my aliases. What error or logs should I check? And also, swaks test is OK.

Syerween commented 1 year ago

This is the logs that i got from docker logs sl-email

#####################################################

2023-03-23 11:30:06 - SL - INFO - "email_handler.py:1634" - _handle() - - ===>> New message, mail from gmail_email@gmail.com, rctp tos ['im@alias_email'] 2023-03-23 11:30:06 - SL - DEBUG - "email_handler.py:1543" - handle() - f7ebd990-0529-4434-ba3c-adcbf0eb1260 - ==>> Handle mail_from:gmail_email@gmail.com, rcpt_tos:['im@alias_email'], header_from:ratbox gmail_email@gmail.com, header_to:im@alias_email, cc:None, reply-to:None, mail_options:['SIZE=4040'], rcpt_options:[] 2023-03-23 11:30:06 - SL - DEBUG - "email_handler.py:1602" - handle() - f7ebd990-0529-4434-ba3c-adcbf0eb1260 - Forward phase gmail_email@gmail.com(ratbox gmail_email@gmail.com) -> im@alias_email 2023-03-23 11:30:06 - SL - DEBUG - "email_handler.py:500" - handle_forward() - f7ebd990-0529-4434-ba3c-adcbf0eb1260 - Create or get contact for from:ratbox gmail_email@gmail.com reply-to:None 2023-03-23 11:30:06 - SL - DEBUG - "email_handler.py:222" - get_or_create_contact() - f7ebd990-0529-4434-ba3c-adcbf0eb1260 - create contact gmail_email@gmail.com for alias <Alias 3 im@alias_email> 2023-03-23 11:30:06 - SL - DEBUG - "email_handler.py:555" - forward_email_to_mailbox() - f7ebd990-0529-4434-ba3c-adcbf0eb1260 - Forward <Contact 3 gmail_email@gmail.com 3> -> <Alias 3 im@alias_email> -> <Mailbox 1 another@email.com> 2023-03-23 11:30:06 - SL - DEBUG - "email_handler.py:694" - forward_email_to_mailbox() - f7ebd990-0529-4434-ba3c-adcbf0eb1260 - message id 167957100681.1.15620607413573167268.14@alias_email 2023-03-23 11:30:06 - SL - DEBUG - "email_handler.py:704" - forward_email_to_mailbox() - f7ebd990-0529-4434-ba3c-adcbf0eb1260 - From header, new:"ratbox - gmail_email at gmail.com" ra+ddajffkieteajjesmckhwqspoylnaksmicrcoyys@alias_email, old:ratbox gmail_email@gmail.com 2023-03-23 11:30:06 - SL - DEBUG - "email_handler.py:317" - replace_header_when_forward() - f7ebd990-0529-4434-ba3c-adcbf0eb1260 - Delete Cc header, old value None 2023-03-23 11:30:06 - SL - DEBUG - "email_handler.py:314" - replace_header_when_forward() - f7ebd990-0529-4434-ba3c-adcbf0eb1260 - Replace To header, old: im@alias_email, new: im@alias_email 2023-03-23 11:30:06 - SL - DEBUG - "email_handler.py:725" - forward_email_to_mailbox() - f7ebd990-0529-4434-ba3c-adcbf0eb1260 - Forward mail from gmail_email@gmail.com to another@email.com, mail_options:['SIZE=4040'], rcpt_options:[] 2023-03-23 11:30:06 - SL - DEBUG - "/code/app/email_utils.py:1122" - sl_sendmail() - f7ebd990-0529-4434-ba3c-adcbf0eb1260 - send email with subject 'hello', from '"ratbox - gmail_email at gmail.com" ra+ddajffkieteajjesmckhwqspoylnaksmicrcoyys@alias_email' to 'im@alias_email' 2023-03-23 11:30:06 - SL - INFO - "email_handler.py:1644" - _handle() - f7ebd990-0529-4434-ba3c-adcbf0eb1260 - takes 0.34596729278564453 seconds <<=== #####################################################

Syerween commented 1 year ago

I followed all troubleshooting steps and they are all good. Not getting any errors. I am not sure where to check next.

Syerween commented 1 year ago

Getting error on sl-app: 2023-03-25 03:41:37 - SL - ERROR - "email_handler.py:1625" - handle_DATA() - b94963de-d459-402f-a04f-84f11e6bc4dd - email handling fail someone@outlook.com -> ['me@mydoman.com']

Traceback (most recent call last): File "/usr/local/lib/python3.7/site-packages/dkim/crypto.py", line 140, in parse_private_key pka = asn1_parse(ASN1_RSAPrivateKey, data) File "/usr/local/lib/python3.7/site-packages/dkim/asn1.py", line 85, in asn1_parse r.append(asn1_parse(t[1], data[i:i+length])) File "/usr/local/lib/python3.7/site-packages/dkim/asn1.py", line 92, in asn1_parse "Unexpected tag (got %02x, expecting %02x)" % (tag, t[0])) dkim.asn1.ASN1FormatError: Unexpected tag (got 30, expecting 02)

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "/usr/local/lib/python3.7/site-packages/dkim/init.py", line 827, in sign pk = parse_pem_private_key(privkey) File "/usr/local/lib/python3.7/site-packages/dkim/crypto.py", line 170, in parse_pem_private_key return parse_private_key(pkdata) File "/usr/local/lib/python3.7/site-packages/dkim/crypto.py", line 142, in parse_private_key raise UnparsableKeyError('Unparsable private key: ' + str(e)) dkim.crypto.UnparsableKeyError: Unparsable private key: Unexpected tag (got 30, expecting 02)

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "email_handler.py", line 1619, in handle_DATA ret = self._handle(envelope) File "email_handler.py", line 1643, in _handle ret = handle(envelope) File "email_handler.py", line 1604, in handle for is_delivered, smtp_status in handle_forward(envelope, msg, rcpt_to): File "email_handler.py", line 540, in handle_forward user, File "email_handler.py", line 718, in forward_email_to_mailbox add_dkim_signature(msg, EMAIL_DOMAIN) File "/code/app/email_utils.py", line 399, in add_dkim_signature include_headers=DKIM_HEADERS, File "/usr/local/lib/python3.7/site-packages/dkim/init.py", line 1335, in sign return d.sign(selector, domain, privkey, identity=identity, canonicalize=canonicalize, include_headers=include_headers, length=length) File "/usr/local/lib/python3.7/site-packages/dkim/init.py", line 829, in sign raise KeyFormatError(str(e)) dkim.KeyFormatError: Unparsable private key: Unexpected tag (got 30, expecting 02)

nguyenkims commented 1 year ago

@Syerween I think this is due to an issue with dkim lib, you can find more info on https://github.com/simple-login/app/discussions/1037

GPConnect commented 1 year ago

hello, my self hosted sl stopped forwarding email all of the sudden after years of good service ! error i get from send email to alias : host alias.xx.xx[xx.xx.xx.xx] said: 554 5.7.1 Service unavailable; Client host [xx.xx.xx.xx] blocked using zen.spamhaus.org; Error: open resolver; https://www.spamhaus.org/returnc/pub/18.134.255.234 (in reply to RCPT TO command)

any help to figure it out ? thanks

nguyenkims commented 1 year ago

@GPConnect it seems that your IP address is blocked by spamhaus and you might need to contact them to unblock your IP address.

GPConnect commented 1 year ago

tested the server ip here https://check.spamhaus.org/ and it say "has no issues"

fm commented 1 year ago

Spamhaus no longer allows queries from open resolvers. https://www.spamhaus.com/resource-center/successfully-accessing-spamhauss-free-block-lists-using-a-public-dns/

GPConnect commented 1 year ago

thanks for your answer ! so how can i resolve my issue ? which step should i follow ?

fm commented 1 year ago

Apply for a free DQS account here, and then install it into rspamd using their module here

JMyrng commented 1 year ago

and then install it into rspamd using their module here

I'm still on version 3.4.0 and had the same problem as @GPConnect. As this version has no direct rspamd install the DQS key has to be inserted in the main.cf file as described here: Configuring DQS on Postfix

With this change I got it working.

MuhammadNaeem42 commented 11 months ago

i will help you to setup this application contact me https://www.fiverr.com/s/9W3PNA simple