Odoo Help

3

4
3 Answers
2
Martin Germany
7/23/13, 7:21 AM

You can patch the file addons/fetchmail/fetchmail.py a little bit. In my case, our e-mail firewall already changes the subject of e-mails, if it is probably spam. I just did this:

@@ -198,6 +198,13 @@
                     result, data = imap_server.search(None, '(UNSEEN)')
                     for num in data[0].split():
                         result, data = imap_server.fetch(num, '(RFC822)')
+                        try:
+                            subject = filter(lambda l: l.startswith("Subject: "), data[0][1].split("\n\n")[0].split("\n"))[0].split(" ", 1)[1]
+                            _logger.info("subject: %s", subject)
+                            if subject.startswith("[SPAM-Firewall]_"):
+                                continue
+                        except Exception, e:
+                            _logger.info("exception with subject %s", str(e))
                         res_id = mail_thread.message_process(cr, uid, server.object_id.model, 
                                                              data[0][1],
                                                              save_original=server.original,

If you don't use a firewall, you could easily use the same mechanism to blacklist subjects, senders etc.

0
Avatar

michel Guénard France

--michel Guénard--

1098
| 5 5 10
VIROFLAY, France
--michel Guénard--

VP operations & finance Social entrepreneur Certified Public Accountant Past Chief internal auditor

michel Guénard France
5/28/13, 6:47 AM

I have used a service from mailstrom.com to clean the email box from spam and other non-desired emails.

2 Comments
GroupMiller, Gary Miller United States
5/31/13, 4:53 PM

This kind of approach seems to imply that I need to make sure that a filter service runs prior to each time OpenERP checks the email account. - Gary

AD LIBITOM, michel Guénard France
5/31/13, 9:23 PM

Services like the one mentionned helps a user to clean his/her mailbox on a continuing basis - as long as the service is active; this is a way to unsubscribe from spam lists. but evidently it does not work as a filter on the fly!

0
Mariusz Mizgier Poland
7/26/13, 4:58 AM

Martin - there is a question if you don't mind answering (I would be very glad to get an answer). I'm interested in importing all mail messages from my account, which has been sent directly to me (for example, if my company is @company.com, then I want to have all mails, which have been addressed to me (like mariusz@company.com, where mariusz is my alias), fetched to OpenERP. Here is the code I've modified:

            result, data = imap_server.search(None, '(ALL)')
            for num in data[0].split():
                result, data = imap_server.fetch(num, '(RFC822)')
                try:
                    to = filter(lambda l: l.startswith("To: "), data[0][1].split("\n\n")[0].split("\n"))[0].split(" ", 1)[1]
                    _logger.info("to: %s", to)
                    if not to.endswith("@company.com"):
                        continue
                except Exception, e:
                    _logger.info("exception with address %s", str(e))
                res_id = mail_thread.message_process(cr, uid, server.object_id.model, 
                                                     data[0][1],
                                                     save_original=server.original,

The problem here is that headers are being processed well, but in the end OpenERP fetch 0 mails - what is the problem here? I wasn't able to trace bug here, whole fetchmail processes as follows, but gives 0 exceptions (and it should). It returns a lot of results like INFO test openrp.addons.fetchmail.fetchmail: to: <mariusz@company.com>, but also mails which are not in the domain @company.com. Any help would be appreciated.

Ask a Question
Writer
Tags
Keep Informed
0 follower(s)
About This Community

This platform is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

Register
Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now