AnsweredAssumed Answered

forwarded email description strips addresses

Question asked by Francesca Shiekh on Jan 18, 2016
Latest reply on Jan 21, 2016 by Francesca Shiekh

Has anyone else noticed that as of v7.6 (possibly prior v7 versions too) when you include forwarded messages in an email the email addresses are stripped from the description?

 

I have an inbound_email queue set up in SugarCRM that users can Bcc or forward to in order to have their communications archived in SugarCRM.

In case of a forward the body of the email is parsed for To/From/Cc lines to extract email addresses and log the emails to the relevant Contacts/Leads.

This worked beautifully in v6.x but...

 

As of v7 when the email is processed by SugarCRM and the records are created in the emails and emails_text table the description field no longer contains the email address.

Therefore in emails_text.description what used to be:

 

From: "Mikey Mouse" <mmouse@disney.com>

To: "Minnie Mouse" <minnie@disney.com>

Sent: Monday, January 18, 2016 11:34:26 AM

Subject: Fwd: Dinner Date

 

becomes

 

From: "Mikey Mouse"

To: "Minnie Mouse"

Sent: Monday, January 18, 2016 11:34:26 AM

Subject: Fwd: Dinner Date

 

Which means the parser can't find any email addresses.

 

I suspect this is because somewhere in the process all html tags are being stripped and the angled brackets around the address make it an "html tag" thus deleting this information.

 

Now, if I use description_html instead of description, the addresses are there, but harder to parse because they are buried inside a table, instead of tidily available in a single line of text that I can run a regex on....

 

 

Using the description_html and  vendor/PHPMailer/extras/class.html2text.php

 

   $h2t = new html2text($html);

   $string = $h2t->get_text();

 

results in:

 

> -------- Forwarded Message --------

>

> SUBJECT:

>

> Fwd: Dinner Date

>

> DATE:

>

> Monday, January 18, 2016 11:34:26 AM

>

> FROM:

>

> Mickey Mouse <mmouse@disney.com>

>

> TO:

>

> Minnie Mouse <minnie@disney.com>

>

> CC:

>

>

 

So now I have a problem with the address and the tag (To/From/CC) not bing on the same line.

 

Does anyone have a better thought on how to extract the original addresses from the body of such a forward?

 

thanks,

FrancescaS

Outcomes