Giter Club home page Giter Club logo

yii2-mailjet's Introduction

Mailjet Client

Create Mailjet Account

https://goo.gl/YNWTwd

Install

composer require weluse/yii2-mailjet

or add it to your composer.json in the require section

"weluse/yii2-mailjet": "*",

Setup

add/replace this in your config under the components key.

'components' => [
  'mailer' => [
    'class' => 'weluse\mailjet\Mailer',
    'apikey' => 'yourApiKey',
    'secret' => 'yourSecret',
  ],
],

Example

Yii::$app->mailer->compose('signup', ['user' => $user])
->setTo($user->email)
->setFrom([Yii::$app->params['noReplyMailAddress'] => Yii::$app->name])
->setSubject('Signup success')
->send();

Attachment example

// Mail with attachment from string via Message::attachContent()
Yii::$app->mailer->compose('view-name')
->setSubject('Mail with attachment from content')
->attachContent("This is the attachment content", ['fileName' => 'attachment.txt', 'contentType' => 'text/plain'])
->setTo('[email protected]')
->send();

// Mail with attachment from file via Message::attach()
$filePath = ... // a file path here;
Yii::$app->mailer->compose('view-name')
->setSubject('Mail with attachment from content')
->attach($filePath)
->setTo('[email protected]')
->send();

Setup Event Tracking

Write the tracking item to the mailer config.

'components' => [
  'mailer' => [
    'class' => 'weluse\mailjet\Mailer',
    'apikey' => 'yourApiKey',
    'secret' => 'yourSecret',
    'tracking' => [
      'bounce' => 'http://yoururl.com/tracking?event=bounce',
    ],
  ],
],

To activate this url you must run this command at one time.

Yii::$app->mailer->activateTracking();

yii2-mailjet's People

Contributors

adrian-gallardo avatar arnaud-g1 avatar dbanck avatar hdoddema avatar julian-b90 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

yii2-mailjet's Issues

Question : compatibility

$ composer require weluse/yii2-mailjet
Using version ^0.1.0 for weluse/yii2-mailjet
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - Can only install one of: mailjet/mailjet-apiv3-php[v1.1.5, v1.1.7].
    - Can only install one of: mailjet/mailjet-apiv3-php[v1.1.7, v1.1.5].
    - Can only install one of: mailjet/mailjet-apiv3-php[v1.1.5, v1.1.7].
    - weluse/yii2-mailjet v0.1.0 requires mailjet/mailjet-apiv3-php 1.1.5 -> satisfiable by mailjet/mailjet-apiv3-php[v1.1.5].
    - Installation request for weluse/yii2-mailjet ^0.1.0 -> satisfiable by weluse/yii2-mailjet[v0.1.0].
    - Installation request for mailjet/mailjet-apiv3-php (locked at v1.1.7, required as ^1.1) -> satisfiable by mailjet/mailjet-apiv3-php[v1.1.7].


Installation failed, reverting ./composer.json to its original content.

Not very experienced all of composer, Yii2, and MailJet so unsure here.
Which is best for me to change? The composer requirement here of the composer file at https://github.com/mailjet/mailjet-apiv3-php/blob/master/composer.json ?

Not even sure what I would change. Thanks in advance for any advice.

Later... this worked, composer update ran ok. But I think I may opened yself up to who-knows-what issues later... ;)

        "mailjet/mailjet-apiv3-php": "*",
        "weluse/yii2-mailjet": "*"

"weluse\mailjet\Mailer::0" should be a url

I get empty posts back from mailjet tracking hooks.
But the endpoints work when tested from the mailjet panel.
I file a ticket at mailjet. They tell me not to use this package.

I find your tracking logic.
It is not clear we when to use this feature... what about the case where they are already in place at mailjet? What if we are not changing our tracker urls all day long?

It is not clear to me how to use this feature.

Since it is a required feature, may we have an example please?
Thank you.

Here s a bad guess:

        Yii::$app->mailer->setTracking([
        
            /*
            ['sent'=>'http://mj.mysite.com/index.php?r=/jet/track/sent'],
            ['open'=>'http://mj.mysite.com/index.php?r=/jet/track/open'],
            ['click'=>'http://mj.mysite.com/index.php?r=/jet/track/click'],
            ['bounce'=>'http://mj.mysite.com/index.php?r=/jet/track/bounce'],
            ['spam'=>'http://mj.mysite.com/index.php?r=/jet/track/spam'],
            ['block'=>'http://mj.mysite.com/index.php?r=/jet/track/block'],
            ['unsub'=>'http://mj.mysite.com/index.php?r=/jet/track/unsub'],
            */
            /*
            ['sent'=>'/jet/track/sent'],
            ['open'=>'/jet/track/open'],
            ['click'=>'/jet/track/click'],
            ['bounce'=>'/jet/track/bounce'],
            ['spam'=>'/jet/track/spam'],
            ['block'=>'/jet/track/block'],
            ['unsub'=>'/jet/track/unsub'],
            */
            ['sent'=>Url::to('/jet/track/sent')],
            ['open'=>Url::to('/jet/track/open')],
            ['click'=>Url::to('/jet/track/click')],
            ['bounce'=>Url::to('/jet/track/bounce')],
            ['spam'=>Url::to('/jet/track/spam')],
            ['block'=>Url::to('/jet/track/block')],
            ['unsub'=>Url::to('/jet/track/unsub')],

        ]);
        Yii::$app->mailer->activateAllTrackings();
        $mi = Yii::$app->mailer->compose()
            ->setFrom('[email protected]')
            ->setTo('[email protected]')
            ->setSubject('Message subject')
            ->setTextBody('Plain text content')
            ->setHtmlBody('<b>HTML content</b>')
            ->send();

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.