{"action":"created","issue":{"url":"https://api.github.com/repos/odoo/odoo/issues/5864","labels_url":"https://api.github.com/repos/odoo/odoo/issues/5864/labels{/name}","comments_url":"https://api.github.com/repos/odoo/odoo/issues/5864/comments","events_url":"https://api.github.com/repos/odoo/odoo/issues/5864/events","html_url":"https://github.com/odoo/odoo/issues/5864","id":63299528,"number":5864,"title":"Notification email has external FROM address.","user":{"login":"yelizariev","id":186131,"avatar_url":"https://avatars.githubusercontent.com/u/186131?v=3","gravatar_id":"","url":"https://api.github.com/users/yelizariev","html_url":"https://github.com/yelizariev","followers_url":"https://api.github.com/users/yelizariev/followers","following_url":"https://api.github.com/users/yelizariev/following{/other_user}","gists_url":"https://api.github.com/users/yelizariev/gists{/gist_id}","starred_url":"https://api.github.com/users/yelizariev/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/yelizariev/subscriptions","organizations_url":"https://api.github.com/users/yelizariev/orgs","repos_url":"https://api.github.com/users/yelizariev/repos","events_url":"https://api.github.com/users/yelizariev/events{/privacy}","received_events_url":"https://api.github.com/users/yelizariev/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":4,"created_at":"2015-03-20T20:15:59Z","updated_at":"2015-04-20T20:25:53Z","closed_at":null,"body":"**Mail server reject notification emails**\r\n\r\nImpacted versions:\r\n\r\n - 8.0. Not sure about master, but it seems that there are no changes about this issue at mail_mail.py file.\r\n\r\nSteps to reproduce:\r\n\r\n 1. set up outgoing mail server via https://pdd.yandex.ru/\r\n 2. set alias for admin: admin@DOMAIN, set email for admin, e.g. ADMIN@gmail.com\r\n 3. activate notification for new emails for admin user\r\n 5. sent external email (e.g. from USER@CUSTOMER) to admin@DOMAIN\r\n\r\nCurrent behavior:\r\n\r\nOdoo trying to send notification email to admin user with parameters as follows:\r\nFROM: USER@CUSTOMER\r\nTO: ADMIN@gmail.com\r\n\r\nYandex mail service reject email with error:\r\nSMTPSenderRefused: 553\r\n5.7.1 Sender address rejected: not owned by auth user.\r\n\r\nExpected behavior:\r\n\r\nFROM value should be replaced, e.g. like this:\r\n\r\nFROM: catchall@DOMAIN\r\nTO: ADMIN@gmail.com\r\n\r\n\r\nThere is no such problem when gmail smtp server is used as outgoing mail server at odoo, because gmail replace wrong FROM field with a gmail account, e.g.\r\nFROM: ivan@gmail.com\r\nTO: ADMIN@gmail.com\r\n\r\nSome mail service can send email with wrong FROM field, but recepient will get warning that email was sent from another server (such behaviour was in notifcation from odoo forum https://www.odoo.com/forum/help-1 )\r\n\r\n\r\npossible solution can be found here: https://github.com/yelizariev/addons-yelizariev/blob/8.0/mail_fix_553/mail_fix_553.py\r\n\r\n\r\n    class mail_mail(osv.Model):\r\n        _inherit = \"mail.mail\"\r\n    \r\n        def send(self, cr, uid, ids, auto_commit=False, raise_exception=False, context=None):\r\n    \r\n            ...\r\n    \r\n            catchall_alias = self.pool['ir.config_parameter'].get_param(cr, uid, \"mail.catchall.alias\", context=context)\r\n            catchall_domain = self.pool['ir.config_parameter'].get_param(cr, uid, \"mail.catchall.domain\", context=context)\r\n    \r\n            correct_email_from = '@%s>?\\s*$'%catchall_domain\r\n            default_email_from = '%s@%s' % (catchall_alias, catchall_domain)\r\n    \r\n            ...\r\n    \r\n            for mail in self.browse(cr, SUPERUSER_ID, ids, context=context):\r\n    \r\n                ...\r\n    \r\n                    for email in email_list:\r\n    \r\n                        email_from = mail.email_from\r\n                        if re.search(correct_email_from, email_from) is None:\r\n                            email_from = default_email_from\r\n    \r\n                        msg = ir_mail_server.build_email(\r\n                            email_from=email_from,\r\n                            ...\r\n"},"comment":{"url":"https://api.github.com/repos/odoo/odoo/issues/comments/94559730","html_url":"https://github.com/odoo/odoo/issues/5864#issuecomment-94559730","issue_url":"https://api.github.com/repos/odoo/odoo/issues/5864","id":94559730,"user":{"login":"mvaled","id":270825,"avatar_url":"https://avatars.githubusercontent.com/u/270825?v=3","gravatar_id":"","url":"https://api.github.com/users/mvaled","html_url":"https://github.com/mvaled","followers_url":"https://api.github.com/users/mvaled/followers","following_url":"https://api.github.com/users/mvaled/following{/other_user}","gists_url":"https://api.github.com/users/mvaled/gists{/gist_id}","starred_url":"https://api.github.com/users/mvaled/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mvaled/subscriptions","organizations_url":"https://api.github.com/users/mvaled/orgs","repos_url":"https://api.github.com/users/mvaled/repos","events_url":"https://api.github.com/users/mvaled/events{/privacy}","received_events_url":"https://api.github.com/users/mvaled/received_events","type":"User","site_admin":false},"created_at":"2015-04-20T20:25:53Z","updated_at":"2015-04-20T20:25:53Z","body":"Hi @yelizariev, @odony,\r\n\r\nWe're actually using an addon that allows to hook into the mail receive/send mechanism of OpenERP.  It is published at https://github.com/merchise-autrement/xopgi.mail_threads.\r\n\r\nWhen we started this addon, the main idea was to extend Odoo's routing mechanism to allow more routing heuristics to be provided.  For instance, we interface with Evaneos (evaneos.com), and its mail system removes the `In-Reply-To` and `References` headers but always uses a unique address to each thread.\r\n\r\nWith our [MailRouter](https://github.com/merchise-autrement/xopgi.mail_threads#mail-routers) we could fix this issue and selectively (ie. by DB) apply it where it should be.\r\n\r\nThis fix is been running in our servers for several months now without problems.  \r\n\r\nMore recently we introduced the concept of [MailTransport](https://github.com/merchise-autrement/xopgi.mail_threads/#mail-transports), that allows to change how to deliver messages.  You may simply change the message's headers, deliver it yourself or chose an outgoing server instead of the default.\r\n\r\nThe first application of this was to use an external (gmail.com): we wanted to have leads received via a gmail account to be replied with that same account.  A 159 lines transport allows to do that.\r\n\r\nAt the moment we're testing a VERP implementation that is a simple combination of a router and a transport, plus a transient model (the one bounced messages are routed to) that allows us to attach the bounces to the right thread and be visible to users.\r\n\r\nNow we're building a transport will be used to replace the outgoing messages with a DMARC-friendly From header. \r\n\r\nBest regards,\r\nManuel."}}