Download the PHP package zanysoft/mail-tracker without Composer
On this page you can find all versions of the php package zanysoft/mail-tracker. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download zanysoft/mail-tracker
More information about zanysoft/mail-tracker
Files in zanysoft/mail-tracker
Package mail-tracker
Short Description Logs and tracks all outgoing emails from Laravel
License MIT
Homepage https://github.com/zanysoft/mail-tracker
Informations about the package mail-tracker
MailTracker
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.
Install
Via Composer
Publish the config file and migration
Run the migration
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.
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.
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.
Events
When an email is sent, viewed, or a link is clicked, its tracking information is counted in the database using the ZanySoft\MailTracker\Model\SentEmail model. This processing is done via dispatched jobs to the default queue in order to prevent the database from being overwhelmed is an email blast situation.
You may want to do additional processing on these events, so an event is fired in these cases:
- ZanySoft\MailTracker\Events\EmailSentEvent
- ZanySoft\MailTracker\Events\ViewEmailEvent
- ZanySoft\MailTracker\Events\LinkClickedEvent
If you are using the Amazon SNS notification system, these events are fired so you can do additional processing.
- ZanySoft\MailTracker\Events\EmailDeliveredEvent (when you received a "message delivered" event, you may want to mark the email as "good" or "delivered" in your database)
- ZanySoft\MailTracker\Events\ComplaintMessageEvent (when you received a complaint, ex: marked as "spam", you may want to remove the email from your database)
- ZanySoft\MailTracker\Events\PermanentBouncedMessageEvent (when you receive a permanent bounce, you may want to mark the email as bad or remove it from your database)
To install an event listener, you will want to create a file like the following:
Then you must register the events you want to act on in your \App\Providers\EventServiceProvider \$listen array:
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:
and then in your event listener:
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.
- ZanySoft\MailTracker\Exceptions\BadUrlLink - Something went wrong with the url link. Either the base 64 encoded url is bad (this only applies to mail sent through version 2.1) or the email hash was not found to apply the link 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 do the php artisan vendor:publish simple views will add to your resources/views/vendor/emailTrakingViews and you can customize.
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.
Security
If you discover any security related issues, please [email protected] instead of using the issue tracker.
License
The MIT License (MIT). Please see License File for more information.
All versions of mail-tracker with dependencies
illuminate/support Version ~6.0|~7.0|~8.0
guzzlehttp/guzzle Version ^5.3.1|^6.2.1|^7.0
aws/aws-php-sns-message-validator Version ^1.1
aws/aws-sdk-php Version ^3.133