Email error for inbox

We have tried to link default Sending and Inbox in email account

then we have only got few emails from the server to erp communication and others are not available neither on the server or on the ERP Communication

Following are the errors we got

pull_from_email_account

 {'retry': 0, 'log': <function log at 0x7efdd6d41de8>, 'site': u'site1.local', 'event': u'all', 'method_name': 
u'pull_from_email_account', 'method': <function pull_from_email_account at 0x7efdd6c90668>, 'user': 
u'Administrator', 
'kwargs': {'email_account': u'Notifications'}, 'async': True, 'job_name': u'pull_from_email_account|Notifications'}
Traceback (most recent call last):
 File "/home/frappe/frappe-bench/apps/frappe/frappe/utils/background_jobs.py", line 66, in execute_job
   method(**kwargs)
   File "/home/frappe/frappe-bench/apps/frappe/frappe/email/doctype/email_account/email_account.py", line 698, in 
pull_from_email_account
email_account.receive()
 File "/home/frappe/frappe-bench/apps/frappe/frappe/email/doctype/email_account/email_account.py", line 253, in receive
emails = email_server.get_messages()
 File "/home/frappe/frappe-bench/apps/frappe/frappe/email/receive.py", line 147, in get_messages
self.pop.dele(m)
 File "/usr/lib/python2.7/poplib.py", line 240, in dele
  return self._shortcmd('DELE %s' % which)
 File "/usr/lib/python2.7/poplib.py", line 160, in _shortcmd
 return self._getresp()
File "/usr/lib/python2.7/poplib.py", line 132, in _getresp
resp, o = self._getline()
File "/home/frappe/frappe-bench/apps/frappe/frappe/email/receive.py", line 557, in _getline
ret = self._super._getline(self, *args, **kwargs)
File "/usr/lib/python2.7/poplib.py", line 112, in _getline
line = self.file.readline(_MAXLINE + 1)
File "/usr/lib/python2.7/socket.py", line 480, in readline
data = self._sock.recv(self._rbufsize)
File "/home/frappe/frappe-bench/env/local/lib/python2.7/site-packages/rq/timeouts.py", line 51, in 
handle_death_penalty
'value ({0} seconds)'.format(self._timeout))
JobTimeoutException: Job exceeded maximum timeout value (300 seconds)

and Other Error Msg is

Error in retrieving email.
Traceback (most recent call last):
 File "/home/frappe/frappe-bench/apps/frappe/frappe/email/receive.py", line 247, in retrieve_message
  msg = self.pop.retr(msg_num)
 File "/usr/lib/python2.7/poplib.py", line 232, in retr
  return self._longcmd('RETR %s' % which)
  File "/usr/lib/python2.7/poplib.py", line 167, in _longcmd
  return self._getlongresp()
 File "/usr/lib/python2.7/poplib.py", line 152, in _getlongresp
  line, o = self._getline()
 File "/home/frappe/frappe-bench/apps/frappe/frappe/email/receive.py", line 557, in _getline
 ret = self._super._getline(self, *args, **kwargs)
 File "/usr/lib/python2.7/poplib.py", line 114, in _getline
raise error_proto('line too long')
error_proto: line too long

Any suggestions why this problem arose and solution for the same

Installed Apps

ERPNext: v8.2.2 (master)

Frappe Framework: v8.2.3 (master)

Please check if you have checked the Use IMAP property in the Email Account, If not then system will use the POP to fetch the email usually POP deletes the email from the servers while fetching emails

it seems that system is taking more than 300 seconds to fetch emails that is causing the Timeout Error

  1. My Existing Config was IMAP Checked In

  2. Will Increasing the the timeout will Help any way

Odd that the traceback refers to poplib when you have imap enabled…

Does this log offer any clues?

frappe@erpnext:~/frappe-bench$ less /var/log/mail.log

You have checked that can you receive emails from a non-ERPNext client?

Getting permission Denied when i tried to get that log
with the given command

and

yes we can get the new mails that are sent from my own server and gmail but lost some hundreds in transition .

Out of Approximately 1500 Mails on the server we only got 200-300 starting with nov 2016 to jan 17 rest of the mails from before nov and from jan to jul lost in transition.

then try ‘sudo less /var/log/mail.log’

yeah tried that also
giving need to be root user so trying as root and will post the result

this is the log

root@ubuntu-x1-mi-fel:~# less /var/log/mail.log
Jul 12 09:33:11 ubuntu-x1-mi-fel postfix[1625]: Postfix is running with backwards-compatible default settings
Jul 12 09:33:11 ubuntu-x1-mi-fel postfix[1625]: See http://www.postfix.org/COMPATIBILITY_README.html for details
Jul 12 09:33:11 ubuntu-x1-mi-fel postfix[1625]: To disable backwards compatibility use "postconf 
compatibility_level=2" and "postfix reload"
Jul 12 09:33:11 ubuntu-x1-mi-fel postfix/master[1662]: daemon started -- version 3.1.0, configuration /etc/postfix
Jul 12 09:33:59 ubuntu-x1-mi-fel postfix[1617]: Postfix is running with backwards-compatible default settings
Jul 12 09:33:59 ubuntu-x1-mi-fel postfix[1617]: See http://www.postfix.org/COMPATIBILITY_README.html for details
Jul 12 09:33:59 ubuntu-x1-mi-fel postfix[1617]: To disable backwards compatibility use "postconf 
compatibility_level=2" and "postfix reload" 
Jul 12 09:33:59 ubuntu-x1-mi-fel postfix/master[1654]: daemon started -- version 3.1.0, configuration /etc/postfix
Jul 12 12:46:34 ubuntu-x1-mi-fel postfix/pickup[2948]: AA93281711: uid=1003 from=<frappe>
Jul 12 12:46:34 ubuntu-x1-mi-fel postfix/cleanup[3627]: AA93281711: message-id=
<20170712124634.AA93281711@ubuntu-x1-mi-fel.web.biz>
Jul 12 12:46:34 ubuntu-x1-mi-fel postfix/qmgr[1656]: AA93281711: from=<frappe@ubuntu-x1-mi-fel.web.biz>, 
size=546, nrcpt=1 (queue active)
Jul 12 12:46:34 ubuntu-x1-mi-fel postfix/local[3629]: AA93281711: to=<root@u/var/log/mail.log
Jul 12 12:46:34 ubuntu-x1-mi-fel postfix/local[3629]: AA93281711: to=<root@ubuntu-x1-mi-fel.web.biz>, orig_to=
<root>, relay=local, delay=0.04, delays=0.02/0.02/0/0, dsn=2.0.0, status=sent (delivered to mailbox)
Jul 12 12:46:34 ubuntu-x1-mi-fel postfix/qmgr[1656]: AA93281711: removed
Jul 12 13:53:45 ubuntu-x1-mi-fel postfix[1603]: Postfix is running with backwards-compatible default settings
Jul 12 13:53:45 ubuntu-x1-mi-fel postfix[1603]: See http://www.postfix.org/COMPATIBILITY_README.html for details
Jul 12 13:53:45 ubuntu-x1-mi-fel postfix[1603]: To disable backwards compatibility use "postconf 
compatibility_level=2" and "postfix reload"
Jul 12 13:53:45 ubuntu-x1-mi-fel postfix/master[1640]: daemon started -- version 3.1.0, configuration /etc/postfix

ok your client side mail log reports nothing suspicious

The ERPNext client seems confused - you selected imap but DEL and RETR are both pop commands that do no succeed - so maybe delete and reset the account settings?

Your port and server settings are correct you say, for eg this check

frappe@erpnext:~/frappe-bench$ nc -vv imap.gmail.com 993
Connection to imap.gmail.com 993 port [tcp/imaps] succeeded!

Port and Server Settings Check below result

login as: frappe
frappe@000.000.000.00's password:
Last login: Wed Jul 12 12:43:24 2017
$ cd frappe-bench
$ nc -vv imap.gmail.com 993
Connection to imap.gmail.com 993 port [tcp/imaps] succeeded!

Can clarify on the delete and reset account ?
i got no emails on the server so if i delete and reset the account will do any good?
because if possible i want all the mails back

I only suggest you reset your ERPNext account settings, to eliminate the apparent pop versus imap confusion. You will need to choose which of the two you prefer.

Sorry I can’t say how or whether old emails possibly can be restored from your backup, if resetting the account now will delete these… apparently imap saves these on the server whereas pop deletes your old emails off the server once they have been downloaded.

The check to confirm your connection in your case would be say for eg

nc -vv imap.secureserver.net 993
nc -vv pop.secureserver.net 995

The above your mail provider must provide.

he is the thing both the connections are success

$ nc -vv pnl0241.prod.sin2.secureserver.net 993
Connection to pnl0241.prod.sin2.secureserver.net 993 port [tcp/imaps] succeeded!

 $ nc -vv pnl0241.prod.sin2.secureserver.net 995
Connection to pnl0241.prod.sin2.secureserver.net 995 port [tcp/pop3s] succeeded!

:confused:

The problem may be a large file attachment that takes more than 300 seconds to download - maybe you or your mail provider can access your server to check for that or a junk email?

A search turned up these example manual login instructions you might try - Manually connecting POP server via telnet command

Actually i have accessed my server and found no email in left in the Inbox of the particular ID which i have connected as Default for Sending and Replies , So, On the server their is no email left and i am getting all the new email from this afternoon to ERP directly,

And what does this error means the Error Which i have attached in the first post

error_proto: line too long

and have just recognised this error log
which says

error_proto: E: xxx@xxx.com

I got approx 11 of this errors before i got timed out error

I would like to know if the Erp Server Pulled the Emails from the EMail Server , Then they need to be stored somewhere in the ERP server , is there a location to check it ?

Because if email Transfer using POP fails the emails should stay on the Email server ,And that didn’t happen , So if POP is successful they should be in the ERP server . Even if they are not showing in the ERPNext UI ?

Error :

{'retry': 0, 'log': <function log at 0x7efdd6d41de8>, 'site': u'site1.local', 'event': u'all', 'method_name': u'pull_from_email_account', 'method': <function pull_from_email_account at 0x7efdd6c90668>, 'user': u'Administrator', 'kwargs': {'email_account': u'Notifications'}, 'async': True, 'job_name': u'pull_from_email_account|Notifications'}
Traceback (most recent call last):
  File "/home/frappe/frappe-bench/apps/frappe/frappe/utils/background_jobs.py", line 66, in execute_job
    method(**kwargs)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/email/doctype/email_account/email_account.py", line 698, in pull_from_email_account
    email_account.receive()
  File "/home/frappe/frappe-bench/apps/frappe/frappe/email/doctype/email_account/email_account.py", line 253, in receive
    emails = email_server.get_messages()
  File "/home/frappe/frappe-bench/apps/frappe/frappe/email/receive.py", line 138, in get_messages
    self.retrieve_message(message_meta, i+1)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/email/receive.py", line 266, in retrieve_message
    self.pop.dele(msg_num)
  File "/usr/lib/python2.7/poplib.py", line 240, in dele
    return self._shortcmd('DELE %s' % which)
  File "/usr/lib/python2.7/poplib.py", line 160, in _shortcmd
    return self._getresp()
  File "/usr/lib/python2.7/poplib.py", line 136, in _getresp
    raise error_proto(resp)
error_proto: 				E: xxx@xxx.com<br />

To find answers, one option is to read the code -

frappe@erpnext:~/frappe-bench$ less -N /usr/lib/python2.7/poplib.py

and inspect the database, ‘bench mysql’ will take you there.

Where you can query any of the few hundred tables.

For example this may have what you want to know?
select * from tabCommunication;

if i download database from backup in ERP UI and the above said database both will be same right ?

Yes they are synonymous. The backup saves a ‘snapshot’ of the database state at a point in time.

Here are example notes Backup & Restore