Email not being sent from a new server with SSL

Hello team,

My ERPnext site2.local was working fine on multi-tenant Server1 which had no SSL certificate. Emails were being sent and there were no issues.

For logistics reasons, I decided to move it to a another server (Server2), and then renamed it to sitename.com (sitename is just for example), and added a LetsEncrypt certificate and SSL connection.

The system is working fine now on Server2, but no emails are being sent, knowing that I maintained the same old configuration of Server1. Both two servers are on digital Ocean cloud, and I am using the same Sendgrid account, and my domain is hosted on Godaddy. The old installation on Server1 is still sending emails without fail, but I am not able to get Server2 two send emails. Any idea what could be the issue?

Regards,
Ahmed

Can you please check for the Email Queue log and share the error message if found any? You can also check Error Log for the error message.

1 Like

Dear @umair,

I found 2 errors in the Error log list.
The first one is:

{
 "attachments": [], 
 "bcc": [], 
 "cc": [
  "sarun@proactengineering.com", 
  "alaa@proactengineering.com", 
  "ramy.sabry@proactengineering.com", 
  "khaled@proactengineering.com", 
  "Shahid.nazir@proactengineering.com"
 ], 
 "communication_name": "1004b2bff7", 
 "lang": "en", 
 "print_format": "Standard", 
 "print_html": "", 
 "recipients": [
  "rachael@thermalimaging.co.uk"
 ]
}
Traceback (most recent call last):
  File "/home/frappe/frappe-bench/apps/frappe/frappe/core/doctype/communication/email.py", line 492, in sendmail
    recipients=recipients, cc=cc, bcc=bcc)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/core/doctype/communication/communication.py", line 181, in _notify
    _notify(self, print_html, print_format, attachments, recipients, cc, bcc)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/core/doctype/communication/email.py", line 178, in _notify
    print_letterhead=True if frappe.flags.print_letterhead=='true' else False
  File "/home/frappe/frappe-bench/apps/frappe/frappe/__init__.py", line 436, in sendmail
    inline_images=inline_images, header=header, print_letterhead=print_letterhead)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/email/queue.py", line 135, in send
    print_letterhead=print_letterhead)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/email/queue.py", line 156, in add
    email_queue = get_email_queue(recipients, sender, subject, **kwargs)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/email/queue.py", line 218, in get_email_queue
    e.insert(ignore_permissions=True)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py", line 219, in insert
    self._validate()
  File "/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py", line 442, in _validate
    self._validate_length()
  File "/home/frappe/frappe-bench/apps/frappe/frappe/model/base_document.py", line 553, in _validate_length
    .format(reference, _(df.label), max_length, value), frappe.CharacterLengthExceededError, title=_('Value too big'))
  File "/home/frappe/frappe-bench/apps/frappe/frappe/__init__.py", line 323, in throw
    msgprint(msg, raise_exception=exc, title=title, indicator='red')
  File "/home/frappe/frappe-bench/apps/frappe/frappe/__init__.py", line 309, in msgprint
    _raise_exception()
  File "/home/frappe/frappe-bench/apps/frappe/frappe/__init__.py", line 282, in _raise_exception
    raise raise_exception(encode(msg))
CharacterLengthExceededError: Email Queue 01ca33e550: 'Show as cc' (sarun@proactengineering.com,alaa@proactengineering.com,ramy.sabry@proactengineering.com,khaled@proactengineering.com,Shahid.nazir@proactengineering.com) will get truncated, as max characters allowed is 140 

And second one is:

{'retry': 0, 'log': <function log at 0x7f087652e398>, 'site': u'proactglobal.com', 'event': u'sendmail', 'method_name': u'sendmail', 'method': <function sendmail at 0x7f0876535a28>, 'user': u'alaa@proactengineering.com', 'kwargs': {'lang': u'en', 'attachments': [], 'recipients': [u'rachael@thermalimaging.co.uk'], 'cc': [u'sarun@proactengineering.com', u'alaa@proactengineering.com', u'ramy.sabry@proactengineering.com', u'khaled@proactengineering.com', u'Shahid.nazir@proactengineering.com'], 'print_letterhead': u'true', 'bcc': [], 'print_html': u'', 'session': {u'data': {u'session_expiry': u'06:00:00', u'session_country': 'AE', 'csrf_token': 'd2532fc85093c4fb02042ebaef1888161567296748744a8ea0c68364', u'last_updated': '2018-03-06 08:49:36.720597', u'lang': u'en', u'user_type': None, 'user': u'alaa@proactengineering.com', u'full_name': None, u'device': u'desktop', 'session_ip': u'176.205.248.63'}, u'user': u'alaa@proactengineering.com', u'sid': u'2d036877dccdf381391092bba7e2a30cc50935bb4bba78fcc203b8b0'}, 'communication_name': '1004b2bff7', 'print_format': u'Standard'}, 'async': True, 'job_name': u'<function sendmail at 0x7f6a326dfc08>'}
Traceback (most recent call last):
  File "/home/frappe/frappe-bench/apps/frappe/frappe/utils/background_jobs.py", line 95, in execute_job
    method(**kwargs)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/core/doctype/communication/email.py", line 492, in sendmail
    recipients=recipients, cc=cc, bcc=bcc)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/core/doctype/communication/communication.py", line 181, in _notify
    _notify(self, print_html, print_format, attachments, recipients, cc, bcc)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/core/doctype/communication/email.py", line 178, in _notify
    print_letterhead=True if frappe.flags.print_letterhead=='true' else False
  File "/home/frappe/frappe-bench/apps/frappe/frappe/__init__.py", line 436, in sendmail
    inline_images=inline_images, header=header, print_letterhead=print_letterhead)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/email/queue.py", line 135, in send
    print_letterhead=print_letterhead)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/email/queue.py", line 156, in add
    email_queue = get_email_queue(recipients, sender, subject, **kwargs)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/email/queue.py", line 218, in get_email_queue
    e.insert(ignore_permissions=True)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py", line 219, in insert
    self._validate()
  File "/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py", line 442, in _validate
    self._validate_length()
  File "/home/frappe/frappe-bench/apps/frappe/frappe/model/base_document.py", line 553, in _validate_length
    .format(reference, _(df.label), max_length, value), frappe.CharacterLengthExceededError, title=_('Value too big'))
  File "/home/frappe/frappe-bench/apps/frappe/frappe/__init__.py", line 323, in throw
    msgprint(msg, raise_exception=exc, title=title, indicator='red')
  File "/home/frappe/frappe-bench/apps/frappe/frappe/__init__.py", line 309, in msgprint
    _raise_exception()
  File "/home/frappe/frappe-bench/apps/frappe/frappe/__init__.py", line 282, in _raise_exception
    raise raise_exception(encode(msg))
CharacterLengthExceededError: Email Queue 01ca33e550: 'Show as cc' (sarun@proactengineering.com,alaa@proactengineering.com,ramy.sabry@proactengineering.com,khaled@proactengineering.com,Shahid.nazir@proactengineering.com) will get truncated, as max characters allowed is 140

In the Email queue log list, many emails are there with status “Not sent”.

Regards,
Ahmed

Any advise guys?

The error appears to be that you have too many email addresses in the cc field when there is a character limit restriction in place for this

Thanks @Julian_Robbins, but I tried sending to one email only also and it still does not go. Does changing the server has an effect?

Hi, did you ever resolve this?