Odoo Help

1
3 Answers
1
Kai Chang
3/8/15, 6:07 PM

I also have same problem.

After one day of investigation, I found the problem is because Zoho only allow you send email from SMTP_USER.

So my fix is change code in /opt/odoo/odoo-server/openerp/addons/base/ir/ir_mail_server.py

You need to change "smtp_from" to "smtp_user" and also replace message['from'] to smtp_user

            try:
                smtp = self.connect(smtp_server, smtp_port, smtp_user, smtp_password, smtp_encryption or False, smtp_debug)
                #smtp.sendmail(smtp_from, smtp_to_list, message.as_string())

                #AIO FIXX 20150308 : Because of Zoho mail does not allow relay mail
                #That means the mail must sent from smtp_user
                #so we replace smtp_from => smtp_user
                #Also need to replace message['From'] to smtp_user
                #Here we only replace email address part but keep email name
                #example: AIO Robotics Inc. <old@email.com> to AIO Robotics Inc. <smtp_user email>
                from email.utils import parseaddr,formataddr
                (oldname,oldemail) = parseaddr(message['From']) #exact name and address
                newfrom = formataddr((oldname,smtp_user)) #use original name with new address
                message.replace_header('From', newfrom) #need to use replace_header instead '=' to prevent double field
                smtp.sendmail(smtp_user, smtp_to_list, message.as_string())
            finally:
                if smtp is not None:
                    smtp.quit()

1 Comment
Hengky Zhang
3/12/15, 2:37 AM

i still cannot send email can you asist me

0
Marcio Marins
10/20/18, 2:21 AM

 Thanks guys!

I use Zoho Mail server as well. In my case, I used the solution of Kai Chang inside of an addon that I built and added the user of the session to the field 'Reply To', right after replacing the header. So then, even the sender being a specific e-mail (like webmaster@domain.com), whenever the receiver reply it, the user who sent the e-mail can receive the response.


message.replace_header('Reply-To', oldemail)    # change the 'Reply To' with the current user

Ask a Question
Tags
Keep Informed
1 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