Email can't send from user but in admin it's work

Hello,

I configure SuiteCRM (7.11.3) and I try to send emails (for a quote). If the sender is the global user, it works well. But, if I use the user account I have an error:
Send error, contact administrator.

In user settings, the outgoing server is correct (I use Gmail).

Can you help me?

Best regards

Try these two checkboxes in Admin / Email settings, see if they make a difference:

Users may send as this account’s identity
Users may send as themselves

Thanks for your reply.

The checkbox work correctly. If I not check, I not see the corresponding account in email.

For my test, I have checked the two checkbox. When I select me in field from, I have an error. If I use SuiteCRM in field from the mail send correctly.

In log I have 4 lines with the error:
[FATAL] SugarPHPMailer encountered and error: Invalid address: (Reply-to): User Name <usermail@gmail.com
[FATAL] SugarPHPMailer encountered and error: Invalid address: (From): User Name <usermail@gmail.com
[FATAL] SugarPHPMailer encountered and error: Invalid address: (From): User Name <usermail@gmail.com
[FATAL] SugarPHPMailer encountered and error: Invalid address: (From): User Name <usermail@gmail.com

I think of a possibility:

Does google authorize to send mail from another address mail?

No, Google will reject your email attempt if you use a “From” email address that doesn’t correspond to the account you’re using.

I have tested with configuring imap and smtp server for user and I have the same error.

I have change log level and this is my log:

Wed Apr 17 11:59:39 2019 [16703][15fb1adc-9a7b-73ad-fcc8-5c877c66feab][ERROR] Unable to find relationship emails_email_templates
Wed Apr 17 11:59:39 2019 [16703][15fb1adc-9a7b-73ad-fcc8-5c877c66feab][ERROR] Invalid email address given: [my name<mymail@gmail.com] Called at /var/www/html/crm/modules/Emails/EmailsController.php:242 from function populateBeanFromRequest.
Wed Apr 17 11:59:39 2019 [16703][15fb1adc-9a7b-73ad-fcc8-5c877c66feab][ERROR] fromUser: Conversion of from user format m/d/Y H:i failed
Wed Apr 17 11:59:39 2019 [16703][15fb1adc-9a7b-73ad-fcc8-5c877c66feab][ERROR] Saving Email with invalid From name and/or Address. Details:
From field is not set.
From address is invalid.
From-name is not set.
From address and name pair format is incorrect, use "from@emailaddress.org " format.
From address and name pair is invalid.
codes:1, 6, 7, 16, 15
Wed Apr 17 11:59:39 2019 [16703][15fb1adc-9a7b-73ad-fcc8-5c877c66feab][ERROR] Unable to find relationship emails_email_templates
Wed Apr 17 11:59:39 2019 [16703][15fb1adc-9a7b-73ad-fcc8-5c877c66feab][ERROR] Invalid email address given: [my name<mymail@gmail.com] Called at /var/www/html/crm/modules/Emails/EmailsController.php:254 from function send.
Wed Apr 17 11:59:39 2019 [16703][15fb1adc-9a7b-73ad-fcc8-5c877c66feab][ERROR] Invalid email address given: [my name<mymail@gmail.com] Called at /var/www/html/crm/modules/Emails/EmailsController.php:254 from function send.
Wed Apr 17 11:59:39 2019 [16703][15fb1adc-9a7b-73ad-fcc8-5c877c66feab][ERROR] Invalid email address given: [my name <mymail@gmail.com] Called at /var/www/html/crm/modules/Emails/EmailsController.php:254 from function send.
Wed Apr 17 11:59:39 2019 [16703][15fb1adc-9a7b-73ad-fcc8-5c877c66feab][ERROR] Invalid email address given: [my name<mymail@gmail.com] Called at /var/www/html/crm/modules/Emails/EmailsController.php:254 from function send.
Wed Apr 17 11:59:39 2019 [16703][15fb1adc-9a7b-73ad-fcc8-5c877c66feab][FATAL] SugarPHPMailer encountered an error: Invalid address: (Reply-To): my name <mymail@gmail.com
Wed Apr 17 11:59:39 2019 [16703][15fb1adc-9a7b-73ad-fcc8-5c877c66feab][ERROR] Invalid email from address or name detected before sending. Details:
From field is not set.
From address is invalid.
From-name is not set.
From address and name pair format is incorrect, use "from@emailaddress.org " format.
From address and name pair is invalid.
codes:1, 6, 7, 16, 15
Invalid address: (Reply-To): my name <mymail@gmail.com
Wed Apr 17 11:59:39 2019 [16703][15fb1adc-9a7b-73ad-fcc8-5c877c66feab][FATAL] SugarPHPMailer encountered an error: Invalid address: (From): my name <mymail@gmail.com
Wed Apr 17 11:59:39 2019 [16703][15fb1adc-9a7b-73ad-fcc8-5c877c66feab][FATAL] SugarPHPMailer encountered an error: Invalid address: (From): my name <mymail@gmail.com
Wed Apr 17 11:59:39 2019 [16703][15fb1adc-9a7b-73ad-fcc8-5c877c66feab][FATAL] SugarPHPMailer encountered an error: Invalid address: (From): my name <mymail@gmail.com
Wed Apr 17 11:59:39 2019 [16703][15fb1adc-9a7b-73ad-fcc8-5c877c66feab][ERROR] send: PHPMailer Exception: { Invalid address: (From): my name <mymail@gmail.com

I found the problem, is a error in code of SuiteCRM.

When I select sender I see

- for system: (Reply-to: My Name <>, From: My Name <info@crm.com>)
- for user:  (Reply-to: My Name <My Name <user@crm.com>>, From: My Name <My Name <user@crm.com>>)

I have logged the function send from SugarPHPMailer

 - for system the From and Sender = info@crm.com
- for user the From and Sender = My Name <user@crm.com

I have updated the function to keep only the mail address and the send work.

I hope this information can you help to correct it for future version.

This is open-source! Can you please do a Pull Request on Github with your proposed fix?

My solution is to modify the file include/SugarPHPMailer.php (line 458) to verify sender and from before send mail.

public function send()
{
	$start = strpos($this->From, ‘<’);
	if($start)
	{
		$start++;
		$this->Sender = $this->From = substr($this->From, $start);
	}

But this solution is not the correct way to solve this issue. I don’t know enough suitecrm to propose the correct correction.

1 Like

I’m also having this issue in 7.11.4 email sends fine from the crm system, but user emails don’t work.

The problem it looks like is it’s adding an extra > at the end of users emails, but not system emails.

From: Administrator <Administrator pstevens@domainname.com>)

On a previous working version it only has one “>” at the end. Any idea where I can find in the code where this extra “>” is?

That doesn’t look like an extra “>”, I would describe the bug as “composing From Name with From Address” twice, instead of only once.

Because that

Administrator <Administrator <pstevens@domainname.com>>

is

Administrator <pstevens@domainname.com>

inside

Administrator < >

In other words, it should be just

FromName <FromAddress>

but instead, it is

FromName <FromName <FromAddress>>

Wow. Does this make sense?

Oh, and when PHPMailer tries to do the parsing, you get an address (like shown in the logs above) like this:

UserName <usermail@gmail.com

which is probably coming from something like this

UserName <UserName <usermail@gmail.com>>

Because if you try to parse for the email address, and grep for “whatever is between a < and a >”, that’s what you get.

You are right, the actual error is:

SugarPHPMailer encountered an error: Invalid address:(Reply-To): Admin <admin@domiainname.com
SugarPHPMailer encountered an error: Invalid address:(From): Admin <admin@domainname .com

So it’s actually parsing out the last “>”

Thought it might be an easy fix. Guess it’s more complicated.

I see there is an issue open for this on Github…

7407

hey @lachinaj

Your fix didn’t work for me on 7.11.4

Just so I’m clear you pasted all the lines beginning with $start = … at line 458?

And it worked for you?

I am optimistic that with this information we have now, it should be pretty straight-forward to fix. It is just a single line somewhere that is putting together a FromName and a FromAddress, without realising there’s already a FromName in that second part. The rest of the errors all derive from this.

Furthermore, with your information on GitHub that this appeared between 7.11.2 and 7.11.4, it narrows down how many changes can be responsible for the regression. I’m trying to see if Dillon has some time to look at this during the following sprints - he knows the email code well enough that he might find the problem relatively fast (fingers crossed).

1 Like

pstevens, I followed the git hub link but do not understand the thread there with D Brown. COuld you please explain the fix for a non programming user?
thank you

I forgot to include
Version 7.11.6, Sugar Version 6.5.25 (Build 344)

Mike: all you need to do is upgrade to the latest, or apply this fix manually:

https://github.com/salesagility/SuiteCRM/commit/b6e370234d36ccbb8cea1648687922efc4466f7d

Thank you Admin, I don’t understand the github page or how to use it.
DO I use these (https://suitecrm.com/upgrade-suitecrm/) to update the CRM? Stupid question but I’m quite new to this.
Mike