This question has been flagged
5 Replies
35752 Views

I'm trying to configure access to a catch-all mail hosted by Zoho.com with my own domain. Everything worked fine before, with a Gmail address (not my domain, just a regular Gmail account) but with Zoho I can't send emails.

1) Incoming is configured for IMAP and working flawlessly.

2) Outgoing is configured as follows:

Description: Zoho (catch-all)

Priority: 10

SMTP Server: smtp.zoho.com

SMTP Port: 465

Debugging: [not flagged]

Connection Security: SSL/TLS

Username: <my_catch_all_email@mydomain.com)< p="">

Password: <password>

The [Test Connection] works but when sending emails from any application I get the infamous message "SMTPServerDisconnected: Connection unexpectedly closed". I already tried to set Alias Domain to 'localhost' and '127.0.0.1' with the same results. Couldn't find much help on the net so I'm posting here...

Thanks in advance for any help!

Avatar
Discard
Best Answer

Hello Guys

here is the module to fix the issue

https://apps.odoo.com/apps/modules/13.0/zoho_mail_fix_spt/

Demo: https://youtu.be/XFofqLoa4ic

Avatar
Discard
Best Answer

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()

Avatar
Discard

i still cannot send email can you asist me

Can you share your code or some logic? I still cannot send

Best Answer

 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

Avatar
Discard

Can you share your code or some logic? I still cannot send

Best Answer

Thanks for Mr. "Kai Chang" and "Marcio Marins"
I used to have the same problem in Odoo v15, but with some help I did the following:

  • I go to file "/usr/lib/python3/dist-packages/odoo/addons/base/models/ir_mail_server.py"
  • Find method `_prepare_email_message`
  • Add some lines just before it's return ' #return smtp_user, smtp_to_list, message '
  • Code:

from email.utils import parseaddr,formataddr
_logger.info('Loooooog smtp_from was ' + smtp_from)
smtp_user = getattr(smtp_session, 'user', False)            #get the user address from smtp
(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)                      #use replace_header instead '=' to prevent double field
_logger.info('Loooooog message[From] become ' + message['From'])
return smtp_user, smtp_to_list, message

just save and restart the service.





Avatar
Discard
Best Answer

OMG Thank you Marcio Marins!

Odoo Version 15.0 (community edition)

ok To get Zoho with custom domains to work in odoo (no-reply@exemple.com)

Step

1. Make sure you at least have the trial or a paid version since the free version doesn't allow you to connect to anything other then their webpage (mail.zoho.com)

2. Make sure you have developer mode (makes things easier)

3. clic on Users & Compagnies (its on the top middle/left of your screen) and choose company

4. select the compagny (default is "My Company")

5. Clic on edit

6. Replace the email you have with the one you're trying to use (ex: 123@gmail.com and replace it with 123@mydomain.com) make sure it's the same one you added to "outgoing Mail Server".

Voila!

Avatar
Discard