Giter Site home page Giter Site logo

mail-tracker's Introduction

MailTracker

Latest Version on Packagist Software License Total Downloads Travis

MailTracker will hook into all outgoing emails from Laravel and inject a tracking code into it. It will also store the rendered email in the database. There is also an interface to view sent emails.

NOTE: If you are using Laravel 9.x you MUST be on version 9.6.0 or higher.

Upgrade from 4.x to 5.x

In 4.x and previous, there was a recipient column in the sent_emails table that stored the RFC standard email format <Name> [email protected]. 5.x has updated to store the name and email separately. The recipient and sender columns have been removed from the sent_emails table migration, but no migration was added to drop those columns. Accessors have been added to retain the model's recipient and sender attributes, so no updates should need to be made to any code that currently uses those unless you are specifically querying the sender or recipient columns.

To retain your existing data afer upgrading, run the artisan command mail-tracker:migrate-recipients. This will convert the existing recipient and sender data into the new format. At this point you may drop the recipient and sender columns.

There is also a new pair of attributes in the sent_emails table: opened_at and clicked_at. Those store the first time the user opened and clicked, respectively. This has been added to the default tracker index page. You are welcome to add it into yours, or use those values as you see fit.

Upgrade from 3.x to 4.x

There are no breaking changes from 3.x to 4.x with the exception that 4.x is for Laravel 7+ only.

Upgrade from 2.x to 3.x

There was a breaking change with the update to version 3.0, specifically regarding the events that are fired. If you are listening for the PermanentBouncedMessageEvent to catch all undeliverables, there are now two separate events: PermanentBouncedMessageEvent will be fired only on permanent bounces, and a new event ComplaintMessageEvent will be fired on complaints. There is also an new event EmailDeliveredEvent that is fired for each successful delivery event. For information about setting up the SES/SNS environment to receive notifications regarding these events, see the documentation below.

Upgrade from 2.0 or earlier

First, upgrade to version 2.2 by running:

composer require jdavidbakr/mail-tracker ~2.2

If you are updating from an earlier version, you will need to update the config file and run the new migrations. For best results, make a backup copy of config/mail-tracker.php and the views in resources/views/vendor/emailTrackingViews (if they exists) to restore any values you have customized, then delete that file and run

php artisan vendor:publish
php artisan migrate

Also note that the migration for the sent_emails_url_clicked table changed with version 2.1.13. The change is that the URL column is now a TEXT field to allow for longer URLs. If you have an old system you may want to manually change that column; there is no migration included to perform that update.

Install

Via Composer

composer require jdavidbakr/mail-tracker

Publish the config file and migration

php artisan vendor:publish --provider="jdavidbakr\MailTracker\MailTrackerServiceProvider"

Run the migration

php artisan migrate

Note: If you would like to use a different connection to store your models, you should update the mail-tracker.php config entry connection before running the migrations.

If you would like to use your own migrations, you can skip this library migrations by calling MailTracker::ignoreMigrations(). For example:

// In AppServiceProvider

public function boot()
{
    MailTracker::ignoreMigrations();
}

Usage

Once installed, all outgoing mail will be logged to the database. The following config options are available in config/mail-tracker.php:

  • name: set your App Name.
  • inject-pixel: set to true to inject a tracking pixel into all outgoing html emails.
  • track-links: set to true to rewrite all anchor href links to include a tracking link. The link will take the user back to your website which will then redirect them to the final destination after logging the click.
  • expire-days: How long in days that an email should be retained in your database. If you are sending a lot of mail, you probably want it to eventually expire. Set it to zero to never purge old emails from the database.
  • route: The route information for the tracking URLs. Set the prefix and middlware as desired.
  • 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 you need to 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.

\Mail::send('email.test', [], function ($message) {
    // ... other settings here
    $message->getHeaders()->addTextHeader('X-No-Track',Str::random(10));
});

Storing content of mails in filesystem

By default, the content of an e-mail is stored in the content column in the database so that the e-mail can be viewed after it has been sent. If a lot of emails are sent, this can consume a lot of memory and slow down the database overall. It is possible to specify in the configuration that the content should be saved to a file in the file system.

    'log-content-strategy' => 'filesystem',
    'tracker-filesystem' => null
    'tracker-filesystem-folder' => 'mail-tracker',

To use the filesystem you need to change the log-content-strategy from database to filesystem. You can specify the disk with tracker-filesystem and the folder it should store the file in with tracker-filesystem-folder.

Overriding models

In some cases you want to override the built-in models. You can do so easily for example in you AppServiceProvider with

MailTracker::useSentEmailModel(YourOwnSentEmailModel::class);
MailTracker::useSentEmailUrlClickedModel(YourOwnSentEmailUrlClickedModel::class);

Your model should implement to SentEmailModel or SentEmailUrlClickedModel interface. This package provides traits to easily implement your own models but not have to reimplement or copy existing code.

use Illuminate\Database\Eloquent\Model;
use jdavidbakr\MailTracker\Concerns\IsSentEmailModel;
use jdavidbakr\MailTracker\Contracts\SentEmailModel;

class OwnEmailSentModel extends Model implements SentEmailModel {
    use IsSentEmailModel;

    protected static $unguarded = true;

    protected $casts = [
        'meta' => 'collection',
        'opened_at' => 'datetime',
        'clicked_at' => 'datetime',
    ];
}

Skip Tracking for Specific Emails

If you have a specific email that you do not want to track, you can add the X-No-Track header to the email. This will prevent the email from being tracked. The header will be removed from the email prior to being sent.

In laravel 9 onwards you can introduce a headers method to your Mailable class. This will stop the tracking pixel/click tracking from applying to the Mailable

public function headers()
{
    return [
        'X-No-Track' => Str::random(10),
    ];
}

Skipping Open/Click Tracking for Anti-virus/Spam Filters

Some mail servers might scan emails before they deliver which can trigger the tracking pixel, or even clicked links. You can add an event listener to the ValidActionEvent to handle this.

class ValidUserListener {
    public function handle(ValidActionEvent $event)
    {
        if (in_array(request()->userAgent(), ['Mozilla/5.0', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/42.0.2311.135 Safari/537.36 Edge/12.246 Mozilla/5.0']) {
            $event->skip = true;
        }
    }
}

Ensure you add the listener to the ValidActionEvent in your EventServiceProvider, if you aren't using automatic event discovery.

## Note on dev testing

Several people have reported the tracking pixel not working while they were testing. What is happening with the tracking pixel is that the email client is connecting to your website to log the view. In order for this to happen, images have to be visible in the client, and the client has to be able to connect to your server.

When you are in a dev environment (i.e. using the `.test` domain with Valet, or another domain known only to your computer) you must have an email client on your computer. Further complicating this is the fact that Gmail and some other web-based email clients don't connect to the images directly, but instead connect via proxy. That proxy won't have a connection to your `.test` domain and therefore will not properly track emails. I always recommend using [mailtrap.io](https://mailtrap.io) for any development environment when you are sending emails. Not only does this solve the issue (mailtrap.io does not use a proxy service to forward images in the emails) but it also protects you from accidentally sending real emails from your test environment.

## Events

When an email is sent, viewed, or a link is clicked, its tracking information is counted in the database using the jdavidbakr\MailTracker\Model\SentEmail model. This processing is done via dispatched jobs to the queue in order to prevent the database from being overwhelmed in an email blast situation. You may choose the queue that these events are dispatched via the `mail-tracker.tracker-queue` config setting, or leave it `null` to use the default queue. By using a non-default queue, you can prioritize application-critical tasks above these tracking tasks.

You may want to do additional processing on these events, so an event is fired in these cases:

-   jdavidbakr\MailTracker\Events\EmailSentEvent
    - Public attribute `sent_email` contains the `SentEmail` model
-   jdavidbakr\MailTracker\Events\ViewEmailEvent
    - Public attribute `sent_email` contains the `SentEmail` model
    - Public attribute `ip_address` contains the IP address that was used to trigger the event
-   jdavidbakr\MailTracker\Events\LinkClickedEvent
    - Public attribute `sent_email` contains the `SentEmail` model
    - Public attribute `ip_address` contains the IP address that was used to trigger the event
    - Public attribute `link_url` contains the clicked URL

If you are using the Amazon SNS notification system, these events are fired so you can do additional processing.

-   jdavidbakr\MailTracker\Events\EmailDeliveredEvent (when you received a "message delivered" event, you may want to mark the email as "good" or "delivered" in your database)
    - Public attribute `sent_email` contains the `SentEmail` model
    - Public attribute `email_address` contains the specific address that was used to trigger the event
-   jdavidbakr\MailTracker\Events\ComplaintMessageEvent (when you received a complaint, ex: marked as "spam", you may want to remove the email from your database)
    - Public attribute `sent_email` contains the `SentEmail` model
    - Public attribute `email_address` contains the specific address that was used to trigger the event
-   jdavidbakr\MailTracker\Events\PermanentBouncedMessageEvent (when you receive a permanent bounce, you may want to mark the email as bad or remove it from your database)
    jdavidbakr\MailTracker\Events\TransientBouncedMessageEvent (when you receive a transient bounce.  Check the event's public attributes for `bounce_sub_type` and `diagnostic_code` to determine if you want to do additional processing when this event is received.)
    - Public attribute `sent_email` contains the `SentEmail` model
    - Public attribute `email_address` contains the specific address that was used to trigger the event

To install an event listener, you will want to create a file like the following:

```php
<?php

namespace App\Listeners;

use jdavidbakr\MailTracker\Events\ViewEmailEvent;

class EmailViewed
{
    /**
     * Create the event listener.
     *
     * @return void
     */
    public function __construct()
    {
        //
    }

    /**
     * Handle the event.
     *
     * @param  ViewEmailEvent  $event
     * @return void
     */
    public function handle(ViewEmailEvent $event)
    {
        // Access the model using $event->sent_email
        // Access the IP address that triggered the event using $event->ip_address
    }
}
<?php

namespace App\Listeners;

use jdavidbakr\MailTracker\Events\PermanentBouncedMessageEvent;

class BouncedEmail
{
    /**
     * Create the event listener.
     *
     * @return void
     */
    public function __construct()
    {
        //
    }

    /**
     * Handle the event.
     *
     * @param  PermanentBouncedMessageEvent  $event
     * @return void
     */
    public function handle(PermanentBouncedMessageEvent $event)
    {
        // Access the email address using $event->email_address
    }
}

Then you must register the events you want to act on in your \App\Providers\EventServiceProvider $listen array:

/**
 * The event listener mappings for the application.
 *
 * @var array
 */
protected $listen = [
    'jdavidbakr\MailTracker\Events\EmailSentEvent' => [
        'App\Listeners\EmailSent',
    ],
    'jdavidbakr\MailTracker\Events\ViewEmailEvent' => [
        'App\Listeners\EmailViewed',
    ],
    'jdavidbakr\MailTracker\Events\LinkClickedEvent' => [
        'App\Listeners\EmailLinkClicked',
    ],
    'jdavidbakr\MailTracker\Events\EmailDeliveredEvent' => [
        'App\Listeners\EmailDelivered',
    ],
    'jdavidbakr\MailTracker\Events\ComplaintMessageEvent' => [
        'App\Listeners\EmailComplaint',
    ],
    'jdavidbakr\MailTracker\Events\PermanentBouncedMessageEvent' => [
        'App\Listeners\BouncedEmail',
    ],
];

Passing data to the event listeners

Often times you may need to link a sent email to another model. The best way to handle this is to add a header to your outgoing email that you can retrieve in your event listener. Here is an example:

/**
 * Send an email and do processing on a model with the email
 */
\Mail::send('email.test', [], function ($message) use($email, $subject, $name, $model) {
    $message->from('[email protected]', 'From Name');
    $message->sender('[email protected]', 'Sender Name');
    $message->to($email, $name);
    $message->subject($subject);

    // Create a custom header that we can later retrieve
    $message->getHeaders()->addTextHeader('X-Model-ID',$model->id);
});

and then in your event listener:

public function handle(EmailSentEvent $event)
{
    $tracker = $event->sent_email;
    $model_id = $event->sent_email->getHeader('X-Model-ID');
    $model = Model::find($model_id);
    // Perform your tracking/linking tasks on $model knowing the SentEmail object
}

Note that the headers you are attaching to the email are actually going out with the message, so do not store any data that you wouldn't want to expose to your email recipients.

Exceptions

The following exceptions may be thrown. You may add them to your ignore list in your exception handler, or handle them as you wish.

  • jdavidbakr\MailTracker\Exceptions\BadUrlLink - Something went wrong with the url link. Basically, the system could not properly parse the URL link to send the redirect to.

Amazon SES features

If you use Amazon SES, you can add some additional information to your tracking. To set up the SES callbacks, first set up SES notifications under your domain in the SES control panel. Then subscribe to the topic by going to the admin panel of the notification topic and creating a subscription for the URL you copied from the admin page. The system should immediately respond to the subscription request. If you like, you can use multiple subscriptions (i.e. one for delivery, one for bounces). See above for events that are fired on a failed message. For added security, it is recommended to set the topic ARN into the mail-tracker config.

Views

When you run the php artisan vendor:publish command, simple views will add to your resources/views/vendor/emailTrakingViews that you can customize. You of course my build your entire admin pages from scratch using these views as a guide.

Admin Panel

MailTracker comes with a built-in administration area. The default configuration that is published with the package puts it behind the can:see-sent-emails middleware; you may create a gate for this rule or change it to use one of your own. You may also change the default prefix as well as disable the admin routes completely.

The route name is 'mailTracker_Index'. The standard admin panel route is located at /email-manager. You can use route names to include them into your existing admin menu. You can customize your route in the config file. You can see all sent emails, total opens, total urls clicks, show individuals emails and show the urls clicked details.

All views (email tamplates, panel) can be customized in resources/views/vendor/emailTrakingViews.

Contributing

Please see CONTRIBUTING and CONDUCT for details.

Security

If you discover any security related issues, please email [email protected] instead of using the issue tracker.

Credits

License

The MIT License (MIT). Please see License File for more information.

mail-tracker's People

Contributors

amamarul avatar bretto36 avatar cannonb4ll avatar christophvh avatar colq2 avatar connecteev avatar danpalmieri avatar depsimon avatar drbyte avatar dwhoop55 avatar gabrielpeixoto avatar imusicjj avatar incraigulous avatar jason-morcos avatar jcalonso avatar jdavidbakr avatar jeffersonsimaogoncalves avatar jeroenverfallie avatar karmendra avatar khuthaily avatar krato avatar laravel-shift avatar louis-l avatar madmikeyb avatar maltonite avatar matsza avatar odunayodev avatar stevenmyhre avatar utkudalmaz avatar veneliniliev avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

mail-tracker's Issues

Using this event PermanentBouncedMessageEvent

Hello,
I'm trying to use this Event, PermanentBouncedMessageEvent but, i think the method don't gave me any data.

I Passed this

` public function handle(PermanentBouncedMessageEvent $event)
{
if($event && $event->email_address){
$Email = EmailList::where('email', $event->email_address)->first();

        if($Email){
            $Email->tipo = 'blacklist';
            $Email->save();
        }
    }
}`

What I'm doing wrong??

Mail tracking breaks phpunit tests when using :memory:

When I run phpunit prior to installing mail-tracker I get all green, after I install mail tracker I get all red. I also tried to install it on a fresh install of laravel to see if I get the same error and sure enough I do. This is my phpunit.xml

    <php>
        <env name="APP_ENV" value="testing"/>
        <env name="CACHE_DRIVER" value="array"/>
        <env name="SESSION_DRIVER" value="array"/>
        <env name="QUEUE_DRIVER" value="database"/>
        <env name="DB_CONNECTION" value="sqlite"/>
        <env name="DB_DATABASE" value=":memory:"/>
        <env name="MAIL_DRIVER" value="log"/>
    </php>

The error I get is

Doctrine\DBAL\Schema\SchemaException: There is no column with name 'message_id' on table 'sent_emails'.

Migration fails on mysql 5.6.21

The newest migration 2016_11_10_213551_add-message-id-to-sent-emails-table.php doesn't work on my mysql version, with error:

SQLSTATE[42000]: Syntax error or access violation: 1101 BLOB/TEXT column 'meta' can't have a default value (SQL: alter table `sent_emails` add `message_id` varchar(255) null, add `meta` text not null default '[]')

I don't think we should need a default value, right?

Class super does not exist

Hi,

I am trying to use your package. i get this error "Class super does not exist" when calling any admin routes.

if i comment out super in mail-tracker.php it appears to work but then when i click view none of those views work.

I am on laravel 5.2.45 and i installed version "jdavidbakr/mail-tracker": "~2.0". and Ran vendor publish
created a route and points too:
Route::get('/email-manager', function()
{
return view('mailTracker_Index');
});

Am i missing anything?

Great package btw 👍

Not working in lumen

I made it work in laravel but when I tried in my lumen project it showed this issue when I tried registering the events.

PHP Fatal error: Call to undefined method Laravel\Lumen\Application::name() in D:\evibe\apis\vendor\jdavidbakr\mail-tracker\src\MailTrackerServiceProvider.php on line 116

Fatal error: Call to undefined method Laravel\Lumen\Application::name() in D:\evibe\apis\vendor\jdavidbakr\mail-tracker\src\MailTrackerServiceProvider.php on line 116

Ability to disable routes

Great package, just started using it.

Currently, the package provides a panel to see the sent emails and their statuses. Problem is that I don't need the routes as I want to display the e-mails in my own panel with my own route names.

Would be great to just disable these routes, currently I attach a middleware to them so the user gets redirected if they would ever 'gues' the url.

Not able to track mails

I am working on laravel 5.3, its storing the mails being sent but not able to track. As nothing is being stored.
I think by those artisan commands the tracking process will work or any other stuff needs to be done.

CC'ing different emails on single email?

Any thoughts on what happens when the emails sent out have multiple people/emails CC'd on the email message being sent?

Used to use Mandrill and loved that it would give each CC email a separate tracking key by keeping all in an array of ids for a given "message". We now use AWS SES and haven't been able to replicate this type of functionality yet - thoughts on this?

Passing a bad hash to MailTrackerController::getL causes error 500

I have found some HTTP 500 errors in the log of my server after deploying the package, and it appears those errors come from the /emails/l route when bad parameters are passed. One specific request has caused these errors:

/emails/l/cJJ3bIH3Nm0afLA8Lceve0fbJZ0me72lc0JdbeDfUACaam4lFUOibSgjX0wlBXFcbs8dbQDsdi4maG9gcL4nbKEcfWhjfKSm/FGnf0pISQBEartpDJ56bBC7alRA4PahR

This request is weird because no email in the database has the hash passed at the end of the url. Looks like some kind of attack.

Since no email sent is found, the controllers' getL method runs the redirect($url) at the end. But the $url parameter passed through the url once decoded is not an url, it's this exact string:

b"pÆwlü¸6m\x1A|░<-û{G█%Ø&{¢ÑsB]mÓ▀P\x00Üjn%\x15Cóm(#_L%\x05q\n¤\x1Dm\x00ýv.&hop¥'lí\x1C}hc|ñª"`

It seems forged...

This string is then used directly in the line redirect($url) at the end of the method! This causes the 500 error.

So, passing a random string shouldn't cause the server to fail. So I've added this piece of code at the beginning of the method so the redirection is made to the domain's root if the redirection url is not valid:

public function getL($url, $hash)
{
    $url = base64_decode(str_replace("$", "/", $url));

    // code added:
    if (filter_var($url, FILTER_VALIDATE_URL) === false) {
        Log::warning('MailTrackerController::getL - the url to redirect to is not valid', ['currentUrl' => request()->url()]);
        return redirect('/');
    }

    // rest of the function...

I can submit a PR if you want.

option for not inserting the content / exception catching for content too long

For my newsletter which is very large and includes a lot of code.. I immediately ran into the "SQLSTATE[22001]: String data, right truncated: 1406 Data too long for column 'content'" error

I was surprised since this is a text column, also I thought the default mysql behaviour was to show a warning but to insert the truncated value anyway.. but I guess not with Laravel.. or maybe that's changed.. anyway it's a fatal error

And now I find it difficult to curb this problem. I'm also sending thousands of newsletters and while I do want to track the opens/clicks on those.. it is not at all necessary for the content of the email to be inserted into the database since it's always the same content anyway

so how can I do that? And do you think maybe we could have an option to disable logging just the content column?

Thanks!

Doesn't log Sent Emails on a multi user platform

Hi,

I am trying to use the package with the Multiuser platform where every user has its own smtp setting. With a multiuser platform it doesn't logs the email sent. Here is the code I am using to send email:

               $transport = new Swift_SmtpTransport($smtp->trans, $smtp->port, $smtp->encr);
                $transport->setUsername($smtp->user_name);
                $transport->setPassword($smtp->password);
                $temp_sender= new Swift_Mailer($transport);
                Mail::setSwiftMailer($temp_sender);
        
                Mail::send('vendor.emailTrakingViews.emails.mensaje', $data, function($message) use ($people, $subject , $sender_email,$sender_name){
                        $message->to($people->email, $people->first_name)
                                ->subject($subject);
                        $message->from($sender_email,$sender_name);
                        $message->getHeaders()->addTextHeader('X-No-Track',str_random(10));
                    });

How to use same hash for multiple email

This library is exactly what I have been looking for! Great work. Save me piles of programming!

My question is:
How to use the same open hash for a group of email.

I am sending out a newsletter to multiple addresses. I really don't need to know about the open or click through for each individual addressee. I would like to know how many were opened. (Like Mailchimp or iContact).

Doesn't work with attachments

I'm trying to add attachments to a tracked email, but it doesn't seem to track opens anymore with attachments.

I'm using a markdown template which was working before adding attachments, so I'm not sure if that's related, but when I add any attachments, the tracking pixel isn't added and links aren't rewritten as tracked links.

Emoji in emails cause MySQL exceptions

Unless the database and connections are configured to use utf8mb4, emojis can't be stored in the 'content' column. It causes an exception from MySQL.

To solve this, one should change the db configuration to use utf8mb4, but I find it is too constraining to impose this only to avoid a potential problem in email tracking.

So I have added a fix that replaces emojis from the content just before it is inserted into the database. I can submit a PR if you want.

How to use this package with Gmail API

Hi,

I am trying to use the package with Gmail API, not sure if this will support that or not. Can you guide me the steps I should take to make the view and then use the gmail api to send the email

RAW Emails

Does this plugin work with raw emails? \Mail::raw()

Storing SentEmail id against model

Hi.

Loving the package so far. I was just wondering if it's possible to get the SentEmail id after the email has been sent so i can store it against a model in my database.

I am writing a system that sends an email reminder, and i'd like to store the mail message against the model in my database. I'm not sure if your code already has the functionality to do it or not.

Would appreciate your input

Pixel tracking on gmail not working

Hi,
I have problem with inject pixel for gmail. I send message with this pixel, but gmail not respond for this, in console I found Failed to load resource: the server responded with a status of 404 () but when I grab link (only my link like https://website.com/email/t/token, not https://ci6.googleusercontent.com/proxy/Lrwi0742pnJJ4eOu1No2MgrFh7Edt5jkPyx_kpbH4q9tJ1TT_SATOURtCkg1E9EC5ve3za2R4lybg49C_jOCWaYbmICNjFHaI_Jbjxolzogidw=s0-d-e1-ft#https://website.com/email/t/token I put it into browser it's works.
Any one have the same problem?

Mail tracking breaks phpunit tests when using :memory:

Please see #26 - I left a comment there but as the issue is already closed I don't know if you wanted a new issue with more proof.

I'm also receiving this issue. It's because add-message-id-to-sent-emails-table migration is modifying multiple columns within a sqlite database which is not supported by Laravel.

Dropping or modifying multiple columns within a single migration while using a SQLite database is not supported.

screen shot 2017-07-25 at 13 37 44

Thus this breaks unit tests where an in-memory SQLite database is used for the 'testing' environment.

For what it's worth I think that you could move this migration into two separate ones, or modify your original migration where you create the Sent Emails Table to add these columns there.

I know you have backwards-compatibility to think of though.

I hope this helps you track down the issue. :)

AWS SNS Subscription

When subscribing to the SNS Topic the subscription remains in the 'PendingConfirmation' state.

Is there some further action/change required to confirm the subscription?

I created the subscription using the endpoint as described in the readme getting the endpoint URL from the /email-manager page view. I have also set the 'sns-topic' in the mail-tracker.php config.

When that URL is opened manually it shows 'MethodNotAllowedHttpException' so I assume its a POST route and the route is working properly.

possible to change which domains are used for the different routes?

I send all emails from api.mydomain.com

my front-end is located at www.mydomain.com

The absolute links I use inside my emails point to my front-end site. But by default this package was changing them to api.mydomain.com

I used URL::forceRootUrl to force it to www.mydomain.com and there I crearted a special /email catchall route that redirects to api.mydomain.com/email and performs the redirect and tracks the click

however for the SNS route I would like it to use api.mydomain.com because I don't want each email view to have to load my whole JS app

so how is it possible to customize the routes and which URLs that are bound to please?

Laravel 5.3 error as Event class no longer exists

When trying to access the tracking pixel url using Laravel 5.3 an error is shown that says App\Events\Event cannot be found.
The tracking still works but a broken image placeholder is shown in most cases.

Better to Track only allowed mails?

Hello,

First, I would like to thank you for this packages, it's works like a charm.
I wonder if it's better to Track only allowed emails and not Track all except specified...

Why? Because sometime mails are sent from a Package and you don't have to ability to add the tag X-No-Track without forking the package. The same things occurs with built-in Laravel email (Password reset, email confirmation ...)

It's a pretty easy fix, I can make a PR if you want

[23000][1452] Cannot add or update a child row: a foreign key constraint fails (`sent_emails_url_clicked`, CONSTRAINT `sent_email_id` FOREIGN KEY (`id`) REFERENCES `sent_emails` (`id`) ON DELETE CASCADE ON UPDATE NO ACTION)

I've just started receiving this error using the package.

I sent 3 test emails with the test template. With the third email, I added another link and it triggered the error above.

I've generated another email with links and none of them work either. The click is registered b/c the email entry in the sent_emails table increments as expected.

Any help would be appreciated and I'm happy to post whatever code snippets are necessary to figure this out.

Error Authentication

Hello, i'm getting this error "Expected response code 250 but got code "530", with message "530 5.7.1 Authentication required " ".

I believe it's the email setup

To make my submissions, I need it to be different emails, so I set the email before sending it this way:

Config :: set ('mail.host', '$host');
Config :: set ('mail.username', \ Auth :: user () -> email);
Config :: set ('mail.password', \ Auth :: user () -> pass_email);
Config :: set ('mail.port', $port);
Config :: set ('mail.encryption', 'ssl');

I think this is generating the error

How can i fix this?

Another typo in index.php

In mail-tracker/src/views/index.blade.php, Line 54,
<a href="{{route('mailTracker_ShowEmail',$email->id)}}" target="_blank">
shold really be, <a href="{{route('mailTracker_SmtpDetail',$email->id)}}" target="_blank">

Best Regards,
Karmendra

Pass template name

Is there a way to pass the template name of the template that was used to sent_emails? This could be really useful for more advanced tracking.. ie Open rates for a specific template et.

Saving additional tracking with listener

It seems as if the Model isn't loading correctly

FatalErrorException in EmailSent.php line 17:
Call to undefined method jdavidbakr\MailTracker\Events\EmailSentEvent::getHeader()

Here is the EmailSent.php

`<?php

namespace App\Listeners;

use jdavidbakr\MailTracker\Events\EmailSentEvent;

class EmailSent
{
public function __construct()
{
//
}

public function handle(EmailSentEvent $event)
{
    $tracker = $event->sent_email;
    $model_id = $event->getHeader('Template-Name');
    $model = Model::find($model_id);

    $tracker->ad = 'test';
    $tracker->save();
}

}
`

Sending to multiple users, link tracking error

Hi there, love using this repo. Thanks so much for it

I've just had an issue on our production server. We sent an email to multiple users at once, but when the links were clicked it couldn't find the correct details.

I found that the links all had the wrong sent_email hash on them for most users. They all shared one user's sent_email entry hash. See below for circled hash, the recipient below that highlighted one in the snip was getting the error. It wasn't refactoring the link to match what it previously was, it was just attempting to add it straight to the database but couldn't because its longer than 255 characters. I have now changed it to send to each user individually, but would prefer to keep them grouped for speed of sending

image

Illuminate\Database\QueryException: SQLSTATE[22001]: String data, right truncated: 1406 Data too long for column 'url' at row 1 (SQL: insert into sent_emails_url_clicked (sent_email_id, url, hash, updated_at, created_at) values (10683, ....

Mail hash is not uniquely generated

MailTracker.php#L122

The hash being generated is using str_random which internally uses php function random_bytes.

This function, although 32 length, could still have a collision, since it does not generate unique values. As such, the database unique constraint would fail and therefore the Mail would fail to send at all.

I suggest either using a uniquely generated hash (perhaps a hash off of the time or the database IDs).

Otherwise, we should probably catch the unique constraint exception and generate a new hash or just skip applying the tracking code to ensure the mail is successfully sent.

Open for discussion.

Mail tracker track all email

Hi jdavidbakr,

Mail tracker is great work, but it's track all emails, I think it should be selectable

Thanks.

small mistake in the docs

In the part of the docs where you explain how to Passing data to the event listeners

this block

public function handle(EmailSentEvent $event)
{
    $tracker = $event->sent_email;
    $model_id = $event->getHeader('X-Model-ID');
    $model = Model::find($model_id);
    // Perform your tracking/linking tasks on $model knowing the SentEmail object
}

should be

    public function handle(EmailSentEvent $event)
    {
        $tracker = $event->sent_email;
        $model_id = $event->sent_email->getHeader('X-Model-ID');
        $model = Model::find($model_id);
        // Perform your tracking/linking tasks on $model knowing the SentEmail object
    }

Otherwise this works great!

Track location

Hi, thanks for creating like this library it's easy and worked without any error, but I am searching how can I track the location of recipients IP or Country,
is that possible with your library?
Thanks

Link tracker to model

Is there a way to link a tracker to a model ?

My application sends emails automatically based on actions such as "OrderShipped" and I'd like to link the tracker to the specific Order so that I can display all emails linked to an Order.

I see there's a meta column in the sent_emails table, how would I edit this according to the notification ?

Tracking code at the top?

I've noticed that the tracking code is shown as the excerpt text when receiving an email on iPhones. Is there a way to change the place of the tracking text so that the subtitle of the email isn' the tracking code?

Thanks

Add option to not save content of some email

Hi there,

First, thanks for sharing this awesome work.

In my case we send a ton of mails and although we want to keep track of it, our DB size is growing really fast, and the content is not that important.

Do you think is possible to set per email basis if we want to save the content?

Perhaps with another Header setting?

No Track causing issue with SES

First, many many thanks for this awesome package!

I am using Amazon SES for mails and I don't want certain mails to be tracked. For this purpose, I have added header as mentioned in docs.
$message->getHeaders()->addTextHeader('X-No-Track', str_random(10));

But this is creating error:
Uncaught Error: Call to a member function getFieldBody() on null in /home/vagrant/code/vendor/jdavidbakr/mail-tracker/src/MailTracker.php:41

EmailView Increments Twice

Hey again - in the spirit of keeping issues separate- I am also having an issue where the 'Clicks' increases by 2 for each click on a link within the email.

Now here is what is really strange... If I right-click-copy the link from within the email (I use GMail) then paste that URL to the address bar and go - a single click is added. Does GMAIL do a preview before sending the user to the link.. I'm not sure.

I removed my Event (LinkClicked) just in case that was the issue.

Any ideas where to start with this...?

Thanks again,
Daniel

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.