@@ -54,14 +54,17 @@ protected function addTrackers($html, $hash)
5454 if (config ('mail-tracker.track-click ' )) {
5555 $ html = $ this ->injectLinkTracker ($ html , $ hash );
5656 }
57-
57+ if (config ('mail-tracker.custom-inject ' )){
58+ $ customInject = config ('mail-tracker.custom-inject-html ' );
59+ $ html = $ this ->customInject ($ html , $ customInject );
60+ }
5861 return $ html ;
5962 }
6063
6164 protected function injectTrackingPixel ($ html , $ hash )
6265 {
6366 // Append the tracking url
64- $ tracking_pixel = '<img src=" ' .route ('mailTracker_t ' ,[$ hash ]).'" /> ' ;
67+ $ tracking_pixel = '<img src=" ' .route ('mailTracker_t ' ,[$ hash ]).'" style="height: 0px; display: inherit;" /> ' ;
6568
6669 $ linebreak = str_random (32 );
6770 $ html = str_replace ("\n" ,$ linebreak ,$ html );
@@ -76,6 +79,20 @@ protected function injectTrackingPixel($html, $hash)
7679 return $ html ;
7780 }
7881
82+ protected function customInject ($ html , $ injectHtml ){
83+ // Append the custom html
84+ $ linebreak = str_random (32 );
85+ $ html = str_replace ("\n" ,$ linebreak ,$ html );
86+
87+ if (preg_match ("/^(.*<body[^>]*>)(.*)$/ " , $ html , $ matches )) {
88+ $ html = $ matches [1 ].$ injectHtml .$ matches [2 ];
89+ } else {
90+ $ html = $ html . $ injectHtml ;
91+ }
92+ $ html = str_replace ($ linebreak ,"\n" ,$ html );
93+ return $ html ;
94+ }
95+
7996 protected function injectLinkTracker ($ html , $ hash )
8097 {
8198 $ this ->hash = $ hash ;
0 commit comments