Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Emails sent from within SuiteCRM have mis-matched boundary ids on copy in sent folder. #5093

Closed
davtonsc opened this issue Feb 5, 2018 · 2 comments

Comments

@davtonsc
Copy link
Contributor

commented Feb 5, 2018

Issue

When I send an email from within SuiteCRM, the copy that is saved to my sent folder on my IMAP server is either gibberish or completely blank depending on which mail agent I'm using. In looking at the source for the copy in the Sent folder the boundary id in the header does not match the boundary ids used below. The email sent to the recipient is correct, it is just the Sent copy that is wrong.

Here is an example of an email:

Date: Mon, 5 Feb 2018 14:47:03 -0500
To: system.administrator@someobfuscateddomain.com
From: My Name <email@someobfuscateddomain.com>
Reply-To:  My Name <email@someobfuscateddomain.com>
Subject: Suite Test 2
Message-ID: <d34403b62899d8aeb1ee93f1c56e57a4@srvlinuxpi.dmz.myorg.local>
X-Mailer: PHPMailer 5.2.25 (https://github.com/PHPMailer/PHPMailer)
MIME-Version: 1.0
Content-Type: multipart/alternative;
	boundary="b1_d34403b62899d8aeb1ee93f1c56e57a4"


This is a multi-part message in MIME format.

--b1_93653c1eab0e17ffb9d08fbe8f42c17f
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

html, no attachments.


--b1_93653c1eab0e17ffb9d08fbe8f42c17f
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.=
w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">=0A<html>=0A<head>=0A</head>=
=0A<body>=0Ahtml, no attachments.=0A</body>=0A</html>


--b1_93653c1eab0e17ffb9d08fbe8f42c17f--

Expected Behavior

The boundary ID in the header should match the boundary IDs used in the parts of the body.

Actual Behavior

The boundary ID in the email header:
Content-Type: multipart/alternative;
boundary="b1_d34403b62899d8aeb1ee93f1c56e57a4"

does not match the boundary ids used in the body of the message:
--b1_93653c1eab0e17ffb9d08fbe8f42c17f
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

--b1_93653c1eab0e17ffb9d08fbe8f42c17f
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
--b1_93653c1eab0e17ffb9d08fbe8f42c17f--

Steps to Reproduce

  1. Send an email from within SuiteCRMs email composer
  2. Compare the source of the message between the copy delivered to the recipient and the copy placed in your Sent folder.

Context

I feel this should be a medium priority issue. It does not prevent the emails from being sent but it makes it impossible to reference the sent emails in your own email program.

Your Environment

  • SuiteCRM Version used: 7.8.10 clean install, also tested with upgrade to 7.8.12
  • Browser name and version: Firefox 58 64-bit
  • Environment name and version: Apache 2.4.29, PHP 7.1.13, MariaDB 10.0.33
  • Operating System and version: Slackware 14.2 64-Bit
@davtonsc

This comment has been minimized.

Copy link
Contributor Author

commented Feb 7, 2018

I believe I have found the issue. The problem is in modules/Emails/Email.php on this line (972 in 7.8 or 1287 in master):

$data = $mail->CreateHeader() . "\r\n" . $mail->CreateBody() . "\r\n";

New boundaries are generated inside of CreateBody so the boundary id used in the header is no longer valid. My fix is to change the line to this:

// Call CreateBody BEFORE CreateHeader as that is where boundary IDs are generated.
$emailbody = $mail->CreateBody();
$emailheader = $mail->CreateHeader();
$data =  $emailheader. "\r\n" . $emailbody . "\r\n";

@davtonsc davtonsc changed the title Emails sent from within SuiteCRM have mis-matched boundry ids on copy in sent folder. Emails sent from within SuiteCRM have mis-matched boundary ids on copy in sent folder. Feb 7, 2018

@davtonsc

This comment has been minimized.

Copy link
Contributor Author

commented Mar 14, 2018

I just submitted a pull request ( #5504 ) for the fix. We have been running this fix for a few weeks now with no issues.
This is my first pull request so please let me know if I messed something up.

Dillon-Brown added a commit that referenced this issue Mar 27, 2018
Merge pull request #5504 from davtonsc/issue-5093
Fixed #5093 - Emails sent from within SuiteCRM have mis-matched bound…

@samus-aran samus-aran closed this in 908296a Apr 3, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants
You can’t perform that action at this time.