Issue with Emails

I have an issue with the Email Module. When I config through SuiteCRM the outbound and inbound emails, it doesn’t work (SMTP ERROR Could not authenticate).
When I pass the outbound email directly in the SugarPHPMailer.php, it works and I can send emails.
But, I have no alternative for the inbound email.
It seems that when I pass the config through SuiteCRM, it doesn’t get the config and I don’t know what file to change for Inbound Email.
I also have another error in my log about email : Unable to find relationship emails_email_templates.
I don’t know what to do. I can only send email, I do see the list of send email, the inbound email doesn’t work.
Can someone help me ?

I’m in SuiteCRM 7.14.4.

I can suggest ways to get more debugging info.

Uncomment this line and check (in the logs, when sending test email) that the values are correct just before being sent to the server:

https://github.com/salesagility/SuiteCRM/blob/master/include/SugarPHPMailer.php#L444

Next, uncomment these lines to get an extensive log of your SMTP interaction with the server. It should provide you with an exact error.

https://github.com/salesagility/SuiteCRM/blob/master/include/SugarPHPMailer.php#L483-L490

You might also want to look at the database table outbound_email to check if the settings look right “under the hood”. There have been bugs with the config screens that cause settings to get saved incorrectly. But these should be fixed in your version…

I did the first two step and when I uncomment the lines and put my smtp config, I can send some Emails but without that I can’t.
And for the Inbound Emails, it seems the same. The settings are not correctly saved from the config screens for outbound and inbound emails.

I can’t explain why uncommenting the logging code would make a difference to the success of sending the emails… or are you talking about uncommenting those other lines to set hard-coded values?

Anyway, consider redoing your email configuration (if by redoing it, it gets saved correctly) or consider setting values directly in the DB.

For this, you will need to work with some fields (I think it’s called stored_options) that are stored in Base64-encoded JSON.

These sites will help you:
→ https://www.base64encode.org/
→ https://www.base64decode.org/

I did hard coded values in purpose of debug to see if it works and it work like that. I already retried to redo my email configuration but it didn’t work either.
I think I will try to pass directly the setting values in the DB. There is no risk to directly set the values in the DB ? And if I perform a quick and repair, does my modifications will be removed from the DB ?
Also, do you know where I find the JSON ?

The risk of changing those values in the DB is taken care of by doing an export of the table as a backup, before beginning.

QR&R won’t touch these tables (inbound and outbound email).

I’m going from memory, but if I recall correctly, one of those tables has the stored_options which looks like it’s encrypted, but it’s just something you run through the base64 decoder and then you’re looking at a JSON array with the options. You can change that (make sure you don’t break anything), run it through the base64 encoder, and put it back in the DB.

@SarahJS Before you get into troubleshooting the code, please follow my video. The email user interface is a little un-user friendly.

Please follow my guide here. If this does not work for you, then we can dig deeper in to the what’s wrong.

1 Like

I did watch your video but it doesn’t work. I tried to create a personal outbound and inbound account linked together like in your videos but it just doesn’t want to authenticate. Same with the system outbound email.

I tried to see in the DB what config it saved but I cannot retrieve the password because it’s stored in hash. But I’m sure this is a password save issue because when I hard coded the password in the SugarPHPMailer.php with $this->Password = ‘myPassword’;, outbound email work so it’s either it’s not stored correctly in the DB or it’s not retrieve correctly when decrypt.
And because I do not know how it’s encrypt I can’t say if it’s the first or the two in this situation.

I also tried to retrieve the stored_options in DB like pgr said but in the JSON, password does not seem to appeared. There is the From_addr, To_addr, etc… but not smtp config. I don’t know if it’s correct.

Do you have any Idea ?

Email works, so I doubt it’s a bug.

So lets review your email setup. What is your email hosting? (ie: gmail, O365, self hosted, etc.)

Do you have an SSL setup for CRM?

Which PHP version are you on?

Have you setup other applications with these email settings that worked?

Have you double checked your login in password is correct by logging in with some other software?

Outbound email only works when I hard coded the password into SugarPHPMailer.php. Otherwise, it doesn’t work. Plus, inbound email don’t work either.
SMTP server is OVH. It’s in TLS but with SSL, it’s the same, that doesn’t work either. PHP is in 8.2 like the compatibility matrix said.
The config works on other application and works when password is hard coded on files so it’s not an issue with the smtp config (server, port, username and password).
Like I said, because it’s an issue with the password, it’s either it doesn’t retrieve the password through the hash in DB or it doesn’t save the password correctly in DB but I cannot say because of the hash.

Like in my video, you have to add your password each time add/change the settings in the inbound email account. If your browser overwrites the field with a saved password it stop working.

I did it and I do not save my passwords on my browser. But I can not see the list of emails in the Emails modules.
Also, why the hash of the outbound email password and the inbound email password are not the same because it’s the same account so the same password. They should have the same hash right ?

No emails are listed in the modules unless you specifically import them.

  1. test the inbound email and click on folders and able to see a list of folders in the email setup? If so your inbound email is setup correctly. Jus save and your good.

  2. test the outbound email by sending a test email. If that gets sent you’re good.

  3. ensure in your profile you subscribe to the emails inbox you wish to see.

  4. go to activities, emails and your inbox should be there.

So, I configured like in your video Inbound emails and it’s setup correctly.
First question is do I have to setup the account for every user (3 on the same mail) or can I setup an inbound email for the 3 people directly ?
Then, I did go to my profile in settings at the bottom and I’ve selected the inbox of the inbound email.
Now in activities/emails, I see a button at the top right of the page named INBOX but when I click on it, and I select it, i return to the emails blank list view.
How can I see the emails I’ve sent from SuiteCRM ?

I have multiple fatal error from IMAP when it tries to import emails.

Wed Jul 31 12:27:27 2024 [11442][7024ba96-7523-8954-a622-6399e4c5a8e5][FATAL] An Imap error detected: "IMAP open error: Can not authenticate to IMAP server: [AUTHENTICATIONFAILED] Authenti>
Wed Jul 31 12:27:27 2024 [11442][7024ba96-7523-8954-a622-6399e4c5a8e5][FATAL] An Imap error detected: "IMAP open error | debug data"
Wed Jul 31 12:27:27 2024 [11442][7024ba96-7523-8954-a622-6399e4c5a8e5][FATAL] An Imap error detected: "ImapHandler:open: {ssl0.ovh.net:993\/service=imap\/tls\/ssl\/secure}INBOX"
Wed Jul 31 12:27:27 2024 [11442][7024ba96-7523-8954-a622-6399e4c5a8e5][FATAL] An Imap error detected: "ImapHandler:open: mymail"
Wed Jul 31 12:27:27 2024 [11442][7024ba96-7523-8954-a622-6399e4c5a8e5][FATAL] An Imap error detected: "ImapHandler:open: password is empty: no"
Wed Jul 31 12:27:27 2024 [11442][7024ba96-7523-8954-a622-6399e4c5a8e5][FATAL] An Imap error detected: "ImapHandler:open: 32768"
Wed Jul 31 12:27:27 2024 [11442][7024ba96-7523-8954-a622-6399e4c5a8e5][FATAL] An Imap error detected: "IMAP open error | debug data end "
Wed Jul 31 12:27:27 2024 [11442][7024ba96-7523-8954-a622-6399e4c5a8e5][FATAL] ImapHandler trying to use a non valid resource stream.
Wed Jul 31 12:27:27 2024 [11442][7024ba96-7523-8954-a622-6399e4c5a8e5][FATAL] An Imap error detected: "IMAP open error:Can not authenticate to IMAP server: [AUTHENTICATIONFAILED] Authentic>
Wed Jul 31 12:27:27 2024 [11442][7024ba96-7523-8954-a622-6399e4c5a8e5][FATAL] ImapHandler trying to use a non valid resource stream.
Wed Jul 31 12:27:27 2024 [11442][7024ba96-7523-8954-a622-6399e4c5a8e5][FATAL] ImapHandler trying to use a non valid resource stream.
Wed Jul 31 12:27:27 2024 [11442][7024ba96-7523-8954-a622-6399e4c5a8e5][FATAL] ImapHandler trying to use a non valid resource stream.
Wed Jul 31 12:27:27 2024 [11442][7024ba96-7523-8954-a622-6399e4c5a8e5][FATAL] Couldn't connect to mail server id: 8a3be141-6a07-9218-8fb4-66aa2ce0c883
Wed Jul 31 12:27:27 2024 [11442][7024ba96-7523-8954-a622-6399e4c5a8e5][ERROR] Unable to connect to IMAP server.

Maybe useful to you:

Thank you but not really helping because I use OVH Mail not Gmail so it’s not the same configuration.
By the way, I’m sure that my configuration is working because when I configure Inbound email, I’m able to see the folder that I want to select.
But it’s like it’s working whenever I’m in the edition of the inbound email but not in Activities/Emails.
When I go to Emails, it’s like it have a wrong config. That’s my issue.

you can found file : include\Imap\Imap2Handler.php
line-》1236:
$emailHeaders = json_decode(json_encode($emailHeaders), true);
change to :$emailHeaders = json_decode(json_encode($emailHeaders,JSON_INVALID_UTF8_IGNORE), true);

if $emailHeaders is false, return error “ImapHandler trying to use a non valid resource stream.”

It doesn’t work either to change that in the include/Imap/Imap2Handler.php

You cannot see the emails you’ve sent from CRM in a list. You can only see them if for example you send to contact “A” and the email is related to contact “A” then you will see the email in the history tab of contact “A”.

You can only see the inbox of your selected email account in activites->emails

One other thought… are you sending as your personal email account or the “system” email account. And did you allow this in email settings or disallow this in email settings?