Email notifications stopped working - UnicodeError: encoding with 'idna' codec failed (UnicodeError: label too long)

This error has started after I upgraded the version. How to resolve this?

Error log for the same is -
UnicodeError: encoding with ‘idna’ codec failed (UnicodeError: label too long)

Failed Background job -

Queue / Worker Job Created
failed
frappe.desk.doctype.event.event.send_event_digest
Traceback (most recent call last):
File “/home/frappe/frappe-bench/env/lib/python3.6/encodings/idna.py”, line 167, in encode
raise UnicodeError(“label too long”)
UnicodeError: label too long

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File “/home/frappe/frappe-bench/env/lib/python3.6/site-packages/rq/worker.py”, line 793, in perform_job
rv = job.perform()
File “/home/frappe/frappe-bench/env/lib/python3.6/site-packages/rq/job.py”, line 599, in perform
self._result = self._execute()
File “/home/frappe/frappe-bench/env/lib/python3.6/site-packages/rq/job.py”, line 605, in execute
return self.func(*self.args, **self.kwargs)
File “/home/frappe/frappe-bench/apps/frappe/frappe/utils/background_jobs.py”, line 102, in execute_job
method(**kwargs)
File “/home/frappe/frappe-bench/apps/frappe/frappe/desk/doctype/event/event.py”, line 163, in send_event_digest
header=[frappe.
(“Events in Today’s Calendar”), ‘blue’]
File “/home/frappe/frappe-bench/apps/frappe/frappe/init.py”, line 489, in sendmail
inline_images=inline_images, header=header, print_letterhead=print_letterhead)
File “/home/frappe/frappe-bench/apps/frappe/frappe/email/queue.py”, line 163, in send
print_letterhead=print_letterhead)
File “/home/frappe/frappe-bench/apps/frappe/frappe/email/queue.py”, line 184, in add
email_queue = get_email_queue(recipients, sender, subject, **kwargs)
File “/home/frappe/frappe-bench/apps/frappe/frappe/email/queue.py”, line 221, in get_email_queue
mail.set_message_id(kwargs.get(‘message_id’),kwargs.get(‘is_notification’))
File “/home/frappe/frappe-bench/apps/frappe/frappe/email/email_body.py”, line 221, in set_message_id
self.msg_root[“Message-Id”] = get_message_id()
File “/home/frappe/frappe-bench/apps/frappe/frappe/email/email_body.py”, line 369, in get_message_id
unique=email.utils.make_msgid(random_string(10)).split(’@’)[0].split(’<’)[1])
File “/usr/lib/python3.6/email/utils.py”, line 204, in make_msgid
domain = socket.getfqdn()
File “/usr/lib/python3.6/socket.py”, line 673, in getfqdn
hostname, aliases, ipaddrs = gethostbyaddr(name)
UnicodeError: encoding with ‘idna’ codec failed (UnicodeError: label too long)

Looking forward to some solution, hint.

Installed Apps

ERPNext: v12.17.0 (version-12)

Erpnext Helper: v0.0.1 (digital-ocean)

Frappe Framework: v12.14.0 (version-12)

Hey, did you solve this?