Skip to content

Commit

Permalink
Merge tag '4.0.11' into update-4.0.11
Browse files Browse the repository at this point in the history
  • Loading branch information
jprodrigues70 committed Jan 26, 2021
2 parents 74c65cc + 2a631b8 commit db8655c
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 19 deletions.
1 change: 0 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ before_install:
- echo "memory_limit=-1" >> ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/travis.ini
- cp ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini ~/xdebug.ini
- phpenv config-rm xdebug.ini
- composer global require hirak/prestissimo --update-no-dev
- composer require "laravel/framework:${LARAVEL_VERSION}" --no-update --prefer-dist
- composer require "orchestra/testbench:${TESTBENCH}" --no-update --prefer-dist

Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ Once installed, all outgoing mail will be logged to the database. The following
- **admin-route**: The route information for the admin. Set the prefix and middleware.
- **admin-template**: The params for the Admin Panel and Views. You can integrate your existing Admin Panel with the MailTracker admin panel.
- **date-format**: You can define the format to show dates in the Admin Panel.
- **content-max-size**: You can overwrite default maximum length limit for `content` database field. Do not forget update it's type from `text` if make it longer.

If you do not wish to have an email tracked, then you can add the `X-No-Track` header to your message. Put any random string into this header to prevent the tracking from occurring. The header will be removed from the email prior to being sent.

Expand Down
4 changes: 4 additions & 0 deletions config/mail-tracker.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,4 +78,8 @@
*/
'tracker-queue' => null,

/**
* Size limit for content length stored in database
*/
'content-max-size' => 65535,
];
34 changes: 17 additions & 17 deletions src/MailTracker.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,13 +65,13 @@ protected function addTrackers($html, $hash)
protected function injectTrackingPixel($html, $hash)
{
// Append the tracking url
$tracking_pixel = '<img border=0 width=1 alt="" height=1 src="'.route('mailTracker_t', [$hash]).'" />';
$tracking_pixel = '<img border=0 width=1 alt="" height=1 src="' . route('mailTracker_t', [$hash]) . '" />';

$linebreak = app(Str::class)->random(32);
$html = str_replace("\n", $linebreak, $html);

if (preg_match("/^(.*<body[^>]*>)(.*)$/", $html, $matches)) {
$html = $matches[1].$matches[2].$tracking_pixel;
$html = $matches[1] . $matches[2] . $tracking_pixel;
} else {
$html = $html . $tracking_pixel;
}
Expand Down Expand Up @@ -101,7 +101,7 @@ protected function inject_link_callback($matches)
$url = str_replace('&amp;', '&', $matches[2]);
}

return $matches[1].route(
return $matches[1] . route(
'mailTracker_n',
[
'l' => $url,
Expand Down Expand Up @@ -132,7 +132,8 @@ public static function hash_url($url)
* @param $buffer
* @return string|string[]|null
*/
protected function sanitizeHtml($html) {
protected function sanitizeHtml($html)
{

if (is_null($html)) {
return null;
Expand Down Expand Up @@ -183,7 +184,8 @@ protected function createTrackers($message)

$original_content = $message->getBody();

if ($message->getContentType() === 'text/html' ||
if (
$message->getContentType() === 'text/html' ||
($message->getContentType() === 'multipart/alternative' && $message->getBody()) ||
($message->getContentType() === 'multipart/mixed' && $message->getBody())
) {
Expand All @@ -202,18 +204,16 @@ protected function createTrackers($message)
}

$tracker = SentEmail::create([
'hash'=>$hash,
'headers'=>$headers->toString(),
'sender_name'=>$from_name,
'sender_email'=>$from_email,
'recipient_name'=>$to_name,
'recipient_email'=>$to_email,
'subject'=>$subject,
'opens'=>0,
'clicks'=>0,
'message_id'=>$message->getId(),
'mailable'=>$mailable,
'meta'=>[],
'hash' => $hash,
'headers' => $headers->toString(),
'sender' => $from_name . " <" . $from_email . ">",
'recipient' => $to_name . ' <' . $to_email . '>',
'subject' => $subject,
'content' => config('mail-tracker.log-content', true) ? (strlen($original_content) > config('mail-tracker.content-max-size', 65535) ? substr($original_content, 0, config('mail-tracker.content-max-size', 65535)) . '...' : $original_content) : null,
'opens' => 0,
'clicks' => 0,
'message_id' => $message->getId(),
'meta' => [],
]);

$content_text = strlen($original_content) > 65535 ? substr($original_content, 0, 65532) . "..." : $original_content;
Expand Down
2 changes: 1 addition & 1 deletion src/MailTrackerController.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class MailTrackerController extends Controller
public function getT($hash)
{
// Create a 1x1 ttransparent pixel and return it
$pixel = sprintf('%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%', 71, 73, 70, 56, 57, 97, 1, 0, 1, 0, 128, 255, 0, 192, 192, 192, 0, 0, 0, 33, 249, 4, 1, 0, 0, 0, 0, 44, 0, 0, 0, 0, 1, 0, 1, 0, 0, 2, 2, 68, 1, 0, 59);
$pixel = sprintf('%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c', 71, 73, 70, 56, 57, 97, 1, 0, 1, 0, 128, 255, 0, 192, 192, 192, 0, 0, 0, 33, 249, 4, 1, 0, 0, 0, 0, 44, 0, 0, 0, 0, 1, 0, 1, 0, 0, 2, 2, 68, 1, 0, 59);
$response = Response::make($pixel, 200);
$response->header('Content-type', 'image/gif');
$response->header('Content-Length', 42);
Expand Down

0 comments on commit db8655c

Please sign in to comment.