Commit graph

130 commits

Author SHA1 Message Date
Suraj Shetty
c0c5b2ebdd
style: format all python files using black (#16453)
Co-authored-by: Frappe Bot <developers@frappe.io>
2022-04-12 10:59:25 +05:30
Faris Ansari
151a95aa30 fix: remove spaces from email placeholders
spaces get converted to %20 which breaks text replacement
2022-04-04 17:11:14 +05:30
Gavin D'souza
b79d55c5d3 refactor(minor): clear_outbox
* Use pluck API instead of building dict and then accesing keys
* Styled query
* Added type hints
2022-03-23 13:18:22 +05:30
shadrak gurupnor
75583bf692 fix: removed redundant pieces & rewrote the query with qb 2022-02-24 18:02:15 +05:30
shadrak gurupnor
c2c858f70e fix: clean up logs job was broken 2022-02-24 09:49:43 +05:30
Gavin D'souza
3446026555 chore: Update header: license.txt => LICENSE
The license.txt file has been replaced with LICENSE for quite a while
now. INAL but it didn't seem accurate to say "hey, checkout license.txt
although there's no such file". Apart from this, there were
inconsistencies in the headers altogether...this change brings
consistency.
2021-09-03 12:02:59 +05:30
Gavin D'souza
d63affc732 refactor(minor): Use ORM instead of raw delete queries
Modified query building for "IN" statements, as well as older condition
builders to use frappe.db.delete
2021-07-28 19:04:18 +05:30
Aradhya-Tripathi
a256219dd2 refactor: moved from raw queries in frappe email to
frappe orm
2021-07-21 19:16:59 +05:30
leela
97ac79a295 fix: consider email account while checking email limits
Added email_account argument for out going email count utility functions as
these are used to validate email limits.
2021-06-11 13:54:54 +05:30
Gavin D'souza
2ad9d202cb Merge branch 'develop' of github.com:frappe/frappe into drop-py2-code 2021-06-03 11:21:55 +05:30
leela
8e3b358b9f refactor: email queue builder is added
replaced queue.send function with Queue builder.
Queue builder builds a queue from sendmail request and sends the mail
if requested to send mail immediately.
2021-06-01 21:39:02 +05:30
Gavin D'souza
e407b78506 chore: Drop dead and deprecated code
* Remove six for PY2 compatability since our dependencies are not, PY2
  is legacy.
* Removed usages of utils from future/past libraries since they are
  deprecated. This includes 'from __future__ ...' and 'from past...'
  statements.
* Removed compatibility imports for PY2, switched from six imports to
  standard library imports.
* Removed utils code blocks that handle operations depending on PY2/3
  versions.
* Removed 'from __future__ ...' lines from templates/code generators
* Used PY3 syntaxes in place of PY2 compatible blocks. eg: metaclass
2021-05-26 15:31:29 +05:30
leela
59bfc12da6 refactor: Cleaned Email Queue sendmail functionality
* Sending mail works independently
* You can send a mail by calling Queue_doc.send()
* Used context manager to track exceptions while sending mails
2021-05-06 10:08:50 +05:30
leela
a8f74d9471 refactor: Move finding email accounts code to EmailAccount doctype 2021-05-03 06:22:35 +05:30
Suraj Shetty
e6f551d610 feat: Add with_container argument and update email style 2021-01-21 11:17:08 +05:30
Saurabh
07e4885775 fix: renaming of fields and test fixes 2020-10-20 13:19:12 +05:30
Saurabh
b23e2cc311 fix: handle encoding exceptions while appending email to sent email folder 2020-08-06 19:09:35 +05:30
Suraj Shetty
a6c68f7dc0
fix: Initialize email_sent_to_any_recipient outsite try block (#10866)
to avoid UnboundLocalError: local variable
'email_sent_to_any_recipient' referenced before assignment
2020-06-30 17:38:27 +05:30
Abhishek Kedar
205c852f1c
fix: removed from_test parameter in send_one function
from_test parameter is not at all used anywhere in the send_one function so removed it, and its value will be always False.
2020-04-28 11:32:24 +05:30
Abhishek Kedar
fda7a45c52
fix: corrected flush job for passing test_flush 2020-04-27 18:25:16 +05:30
Abhishek Kedar
47446469bd
refactor: moved import to the top of the file 2020-04-13 20:20:02 +05:30
Abhishek Kedar
8e9d642f44
style: formatted parameters of enqueue function 2020-04-13 20:11:54 +05:30
Abhishek Kedar
7b10a2d88a
style: removed comment and formatted dictionary 2020-04-13 20:07:46 +05:30
Abhishek Kedar
5b170c031d
perf: enqueue instance of send_one for better performance
Usecase: Suppose I have hundred's of emails in the Email Queue and the flush job executes. While the execution of the flush job is going another flush job starts and so on. Because of this a list of flush jobs gets lined up in the background jobs queue. 
To avoid this it is better to enqueue the send_one function inside the flush job this will very efficiently improve the performance of the flush job.
2020-04-13 16:40:09 +05:30
sahil28297
b1d42e1302
fix: consider Not Sent and Sending status while pulling daily e… (#9496)
Co-authored-by: Saurabh <saurabh6790@gmail.com>
2020-02-18 15:43:16 +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
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
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
Saurabh
6d8da3e057 fix: handle smtp recipients refused exception 2019-09-29 18:15:57 +05:30
gavin
67550fd9a2 fix: fixed email count for current month (#8454) 2019-09-18 22:55:19 +05:30
deepeshgarg007
8521e4f51e fix: Remove email limit check from frappe 2019-08-13 17:06:00 +05:30
Suraj Shetty
b6c56ff94f fix(postres): Pass tuple of all_ids instead of an array
- Fixes failing build for postgres
2019-06-19 11:18:57 +05:30
Nabin Hait
b375ee9eef fix: merge conflict 2019-06-18 18:45:21 +05:30
Himanshu Mishra
0fa0d4324a perf: Don't fetch complete global unsubscribe (#7578)
* Update queue.py

* Update email_unsubscribe.json

* Update email_unsubscribe.json
2019-05-29 17:49:48 +05:30
Sagar Vora
17b20b22a3 Merge branch 'master' into develop 2019-02-12 16:31:54 +05:30
Faris Ansari
1d5310166d fix: Set default print language in Notification 2019-02-07 18:18:01 +05:30
Sagar Vora
47c0d10631 Merge branch 'staging' into develop 2019-01-22 15:43:40 +05:30
Sagar Vora
2d166e7513 Merge branch 'master' into staging-fixes 2019-01-22 15:24:48 +05:30
Zarrar
3d95621cd5 feat(email): Retry sending Email 3 times before deeming it as error (#6754)
* added field to note number of retries

* incase of unprecedented errors increase retry counter and try sending again
2019-01-18 13:33:59 +05:30
Faris Ansari
f23700d33a
Merge pull request #6586 from Thunderbottom/email-attachment-fix
communication: fix attachments in email queue and generated reports
2018-12-07 16:38:05 +05:30
Chinmay Pai
ba0045ef1f
communication: fix attachments in email queue and generated reports
so, apparently i messed up some things that were responsible for handling file attachments in email queue and attached on-the-fly generated reports. these issues should be fixed now.

Signed-off-by: Chinmay Pai <chinmaydpai@gmail.com>
2018-12-06 18:12:34 +05:30
Aditya Hase
f93a141a73 fix(email-queue): Record raised exception and traceback in Error Log 2018-11-15 16:22:13 +05:30
Ameya Shenoy
d0e7690ae2
Merge branch 'staging' into develop 2018-11-05 06:48:46 +00:00
Ameya Shenoy
2ead222090 fix(email): Email status changes to Read (#6396)
The email recieved template was in unsubscribe email. Hence it
didn't used to function in case the emails were sent from DocTypes
like Issue, wherein the unsubscribe email template is not used.
Moved it to email_footer template.

Signed-off-by: Ameya Shenoy <shenoy.ameya@gmail.com>
2018-11-05 10:49:18 +05:30
Ameya Shenoy
e551153ea0
Merge branch 'staging' into develop 2018-09-26 07:21:28 +00:00