Commit graph

804 commits

Author SHA1 Message Date
mergify[bot]
84c04baa4a
Merge pull request #9199 from Thunderbottom/email-server-ref-fix
fix(email): define email_server before condition
2020-01-05 18:58:50 +00:00
Chinmay D. Pai
fb511b1dfd
fix(email): check if communication hasattr for attachment
fixes issue where previous communication has no attribute _attachments
before it fails, causing the following error:

Traceback (most recent call last):
  File "/home/frappe/frappe-bench/apps/frappe/frappe/utils/background_jobs.py", line 99, in execute_job
    method(**kwargs)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/email/doctype/email_account/email_account.py", line 724, in pull_from_email_account
    email_account.receive()
  File "/home/frappe/frappe-bench/apps/frappe/frappe/email/doctype/email_account/email_account.py", line 295, in receive
    attachments = [d.file_name for d in communication._attachments]
AttributeError: 'Communication' object has no attribute '_attachments'

Signed-off-by: Chinmay D. Pai <chinmaydpai@gmail.com>
2020-01-05 00:35:06 +05:30
mergify[bot]
7171a2bb27
Merge pull request #9189 from Thunderbottom/email-encode-fix
fix(email): safe_encode to avoid smtp ascii encoding issue
2020-01-04 08:30:19 +00:00
Chinmay D. Pai
ba9d6020e6
chore: check if email_server exists before handling bad emails
Signed-off-by: Chinmay D. Pai <chinmaydpai@gmail.com>
2020-01-04 12:19:57 +05:30
Chinmay D. Pai
68659c5519
fix(email): define email_server before condition
fixes issue where email_server is unhandled in test

Traceback (most recent call last):
  File "/home/chnmy/workspace/frappe/benches/master-bench/apps/frappe/frappe/email/doctype/email_account/test_email_account.py", line 44, in test_unread_notification
    self.test_incoming()
  File "/home/chnmy/workspace/frappe/benches/master-bench/apps/frappe/frappe/email/doctype/email_account/test_email_account.py", line 35, in test_incoming
    email_account.receive(test_mails=test_mails)
  File "/home/chnmy/workspace/frappe/benches/master-bench/apps/frappe/frappe/email/doctype/email_account/email_account.py", line 291, in receive
    self.handle_bad_emails(email_server, uid, msg, frappe.get_traceback())
UnboundLocalError: local variable 'email_server' referenced before assignment

Signed-off-by: Chinmay D. Pai <chinmaydpai@gmail.com>
2020-01-04 11:51:49 +05:30
Himanshu Warekar
1b4ecdf792 fix: unreferenced variable 2020-01-04 09:26:23 +05:30
Chinmay D. Pai
250c44bed8
chore: pass email_body test
Signed-off-by: Chinmay D. Pai <chinmaydpai@gmail.com>
2020-01-03 23:14:08 +05:30
Chinmay D. Pai
ce2a0854db
fix(email): safe_encode to avoid smtp ascii encoding issue
fixes issue where smtplib fails to encode the mail as ascii

Traceback (most recent call last):
  File "/home/frappe/frappe-bench/apps/frappe/frappe/app.py", line 60, in application
    response = frappe.api.handle()
  File "/home/frappe/frappe-bench/apps/frappe/frappe/api.py", line 55, in handle
    return frappe.handler.handle()
  File "/home/frappe/frappe-bench/apps/frappe/frappe/handler.py", line 22, in handle
    data = execute_cmd(cmd)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/handler.py", line 61, in execute_cmd
    return frappe.call(method, **frappe.form_dict)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/__init__.py", line 1042, in call
    return fn(*args, **newargs)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/core/doctype/user/user.py", line 801, in reset_password
    user.reset_password(send_email=True)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/core/doctype/user/user.py", line 234, in reset_password
    self.password_reset_mail(link)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/core/doctype/user/user.py", line 253, in password_reset_mail
    "password_reset", {"link": link}, now=True)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/core/doctype/user/user.py", line 298, in send_login_mail
    delayed=(not now) if now!=None else self.flags.delay_emails, retry=3)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/__init__.py", line 476, in sendmail
    inline_images=inline_images, header=header, print_letterhead=print_letterhead)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/email/queue.py", line 162, in send
    print_letterhead=print_letterhead)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/email/queue.py", line 185, in add
    send_one(email_queue.name, now=True)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/email/queue.py", line 475, in send_one
    raise e
  File "/home/frappe/frappe-bench/apps/frappe/frappe/email/queue.py", line 415, in send_one
    smtpserver.sess.sendmail(email.sender, recipient.recipient, message)
  File "/usr/lib64/python3.6/smtplib.py", line 855, in sendmail
    msg = _fix_eols(msg).encode('ascii')
UnicodeEncodeError: 'ascii' codec can't encode characters in position 335-339: ordinal not in range(128)

Signed-off-by: Chinmay D. Pai <chinmaydpai@gmail.com>
2020-01-03 14:56:15 +05:30
Chinmay D. Pai
4c138390b6
fix: move email status check to fix travis
mail status wasn't being set when the check was run, so the output for
any() would always be false, and none of the mails would have status set
to sent in the backend. moving the check to a point after setting status
for each email should fix this issue

Signed-off-by: Chinmay D. Pai <chinmaydpai@gmail.com>
2020-01-01 11:21:53 +05:30
Suraj Shetty
e2935b5ba6 refactor: Commonify sent mail checks
-and fix formatting
2019-12-31 21:09:40 +05:30
Suraj Shetty
295c5f89f1
Merge branch 'develop' into email_ssl 2019-12-31 20:47:11 +05:30
Suraj Shetty
50e014f853
Merge branch 'develop' into bytes-fix 2019-12-31 15:38:02 +05:30
Suraj Shetty
3c3516a652 fix(email): Do not encode smtp_server value (#9137)
* fix: Do not encode smtp server

Because it breaks in python 3

* fix: use cstr to change text_type to str

Signed-off-by: Chinmay D. Pai <chinmaydpai@gmail.com>

Co-authored-by: Chinmay Pai <chinmaydpai@gmail.com>
2019-12-28 11:21:08 +05:30
Chinmay D. Pai
4d48a2a032
fix(email): handle case where cstr returns text_type of str
chardet requires input to be bytes or bytesarray, but sometimes
frappe.cstr() returns text_type of str without encoding it to utf-8

Signed-off-by: Chinmay D. Pai <chinmaydpai@gmail.com>
2019-12-27 16:28:09 +05:30
Chinmay D. Pai
6357a4a9a5
feat(email): allow ssl for outgoing emails, append to sent folder
* dont always use default outgoing account for sending
* allow ssl for outgoing emails

Signed-off-by: Chinmay D. Pai <chinmaydpai@gmail.com>
2019-12-18 16:18:44 +05:30
cjpit
f34af5bc25 fix: rfc5322 compliance for python3 (#8912)
* start of tests

* rfc compliant emails for frappe.

* fix for deepsource

* fix length of strings.

* fix bug that I'm not sure where it came from?

* codacy and deepsource issues trying to keep them happy

* take a punt in the dark

* fix: use SMTPUTF8 instead of SMTP and other minor fixes

Signed-off-by: Chinmay D. Pai <chinmaydpai@gmail.com>
2019-12-17 14:01:52 +05:30
Chinmay Pai
d169f41a54 fix(email): try to encode email part to utf-8 (#8965)
fixes issues with class objects other than str

Traceback (most recent call last):
  File "/home/frappe/frappe-bench/apps/frappe/frappe/email/doctype/email_account/email_account.py", line 281, in receive
    communication = self.insert_communication(msg, args=args)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/email/doctype/email_account/email_account.py", line 338, in insert_communication
    email = Email(raw)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/email/receive.py", line 372, in __init__
    self.parse()
  File "/home/frappe/frappe-bench/apps/frappe/frappe/email/receive.py", line 393, in parse
    self.process_part(part)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/email/receive.py", line 445, in process_part
    self.text_content += self.get_payload(part)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/email/receive.py", line 489, in get_payload
    charset = self.get_charset(part)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/email/receive.py", line 484, in get_charset
    charset = chardet.detect(frappe.safe_encode(part))['encoding']
  File "/home/frappe/frappe-bench/env/lib/python3.6/site-packages/chardet/__init__.py", line 34, in detect
    '{0}'.format(type(byte_str)))
TypeError: Expected object of type bytes or bytearray, got: <class 'email.message.Message'>

Signed-off-by: Chinmay D. Pai <chinmaydpai@gmail.com>
2019-12-09 19:25:43 +05:30
Faris Ansari
488c68df96
Merge branch 'develop' into refactor-scheduler 2019-12-02 13:16:45 +05:30
Jack
a7315a7832 fix: Typo in email account doctype (#8864) 2019-11-21 16:48:01 +05:30
mergify[bot]
1ff5089fec
Merge pull request #8596 from ruchamahabal/email_fix
fix(Email): poplib.error_proto exception
2019-11-14 05:35:55 +00:00
Rushabh Mehta
0035772f8f fix(tests) 2019-11-07 12:14:09 +05:30
Rushabh Mehta
7cd329fac9 reactor(scheduler): created "Scheduler Job Type" and cleaned up scheduler 2019-11-07 12:14:09 +05:30
sahil28297
d53dc85fc1
fix(queue): use send_one as email_queue is now an object
TypeError: 'EmailQueue' object is not callable
2019-10-31 18:55:03 +05:30
Shivam Mishra
30052bb403 fix: typo in email template 2019-10-30 14:15:28 +05:30
Rohan Bansal
c1a0deeb7e fix: build filter metadata before allowing user to send email 2019-10-29 13:31:41 +05:30
mergify[bot]
396a402254
Merge pull request #8612 from Alchez/dev-auto-email-links
feat: add hyperlinks to Link fields in auto email reports
2019-10-22 12:47:57 +00:00
Aditya Hase
7b405bbc5b
style: Remove trailing space 2019-10-22 13:04:09 +05:30
Aditya Hase
5b6b10fc27
Update unhandled_email.py 2019-10-22 13:03:00 +05:30
Aditya Hase
cef8f4d450
Update unhandled_email.py 2019-10-22 13:03:00 +05:30
Aditya Hase
83c10c9263
perf(database): Regularly clean old unhandled emails
Co-authored-by: sahil28297 <sahilkhan28297@gmail.com>
2019-10-22 13:03:00 +05:30
Rohan Bansal
69dfb4a1a6 fix: tests 2019-10-18 16:36:37 +05:30
Rucha Mahabal
ac41e46ed6 fix(Email): poplib.error_proto exception 2019-10-13 20:48:54 +05:30
Rohit Waghchaure
30f30d57ff fix: notification is not working if recipients is not set and cc is set 2019-10-11 19:13:44 +05:30
sahil28297
d97689f33a
fix(email_domian): set domain_name as non_unique 2019-10-09 14:26:26 +05:30
mergify[bot]
4acf9ad543
Merge pull request #8514 from saurabh6790/handle_SMTPRecipientsRefused_exception
fix: handle smtp recipients refused exception
2019-10-02 07:07:36 +00:00
Chinmay D. Pai
e2f4c076c7
fix(notifications): do not send emails if no recipients
notifications triggered through hooks have no checks for recipients, if
no recipients exist, sending mails shouldn't be attempted

Signed-off-by: Chinmay D. Pai <chinmaydpai@gmail.com>
2019-09-30 15:41:16 +05:30
Saurabh
6d8da3e057 fix: handle smtp recipients refused exception 2019-09-29 18:15:57 +05:30
Saurabh
c64dece0dd feat: allow custom imap port (#8305)
* feat: allow custom imap port

* fix: use default port if not specified

* fix: pop3 port

* fix: common code to set the incomming port

* fix: codacy
2019-09-25 23:04:05 +00:00
gavin
7ef5b20ca4 fix: fixed email count for current month (#8452) 2019-09-18 22:55:35 +05:30
Himanshu Warekar
46c4f7ba31 fix: dont return admin and guest placeholder email 2019-09-12 16:05:27 +05:30
Rucha Mahabal
0c44fb837d fix: Dont allow sending Newsletter when there are 0 recipients (#8362) 2019-09-08 13:46:47 +05:30
Sagar Vora
cfd7f8bf37 fix: incorrect if condition in smtp module 2019-09-07 12:54:52 +05:30
mergify[bot]
a56b325433
Merge pull request #8348 from surajshetty3416/fix-field-label
fix: Rename Reference DocType -> Reference Document Type
2019-09-05 11:28:51 +00:00
Chinmay Pai
6028b6602f
chore: remove unused get_limits method (#8346)
* chore: remove unused get_limits method

Signed-off-by: Chinmay D. Pai <chinmaydpai@gmail.com>

* chore: remove misleading docstring from email_queue

Signed-off-by: Chinmay D. Pai <chinmaydpai@gmail.com>
2019-09-05 16:12:04 +05:30
Suraj Shetty
2242146c82 fix: Rename Reference DocType -> Reference Document Type 2019-09-05 15:47:40 +05:30
mergify[bot]
005c1951b0
Merge pull request #8204 from ashish-greycube/patch-8
fix(email): AttributeError: 'Message' object has no attribute 'encode' #8148
2019-08-21 08:20:12 +00:00
Suraj Shetty
3eb6a22989
fix: Remove unwanted str() 2019-08-21 13:28:14 +05:30
Ashish Shah
4c7cbd6d7a
Update receive.py 2019-08-21 12:01:06 +05:30
Sahil Khan
9b65a7c4a1 Merge branch 'version-12-hotfix' into merge_v12_hotfix_1 2019-08-20 16:09:39 +05:30
Ashish Shah
b8803a51ad
Update receive.py 2019-08-19 18:34:52 +05:30