Coder Social home page Coder Social logo

lekoala / silverstripe-mandrill Goto Github PK

View Code? Open in Web Editor NEW
18.0 6.0 18.0 665 KB

Mandrill integration for Silverstripe

Home Page: https://github.com/lekoala/silverstripe-mandrill

License: MIT License

PHP 99.60% Scheme 0.40%
silverstripe silverstripe-4 silverstripe-module mandrill php silverstripe-5

silverstripe-mandrill's Introduction

SilverStripe Mandrill module

Build Status Scrutinizer Code Quality Code Coverage Build Status codecov.io

Latest Stable Version Latest Unstable Version Total Downloads License Monthly Downloads Daily Downloads

codecov.io

Use Mandrill in SilverStripe

Define in your .env file the following constant

MANDRILL_API_KEY='YOUR_API_KEY_HERE'

or by defining the api key in your config.yml

LeKoala\Mandrill\MandrillHelper:
    mandrill_api_key: "key3goes9here"

This module uses the official php sdk version 1.0.54 with a few tweaks.

You can also autoconfigure the module with the following constants in your .env file

# Will log emails in the temp folders
MANDRILL_ENABLE_LOGGING=true
# Will disable sending (useful in development)
MANDRILL_SENDING_DISABLED=true
# Set app domain explicitly
MANDRILL_DOMAIN="mysite.co.nz"
# Also recommended to specify an explicit from
SS_SEND_ALL_EMAILS_FROM="[email protected]"

By defining the Api Key, the module will register a new mailer that will be used to send all emails.

Integration

This module create a new admin section that allows you to see results from your api calls right from the SilverStripe CMS without having to log into mandrillapp.com

Webhooks

From the Mandrill Admin, you can setup a webhook for your website. This webhook will be called and MandrillController will take care of handling all events for you.

By default, MandrillController will do nothing. Feel free to add your own extensions to MandrillController to define your own rules, like "Send an email to the admin when we receive a spam complaint".

MandrillController provides 4 extensions points:

  • updateHandleAnyEvent
  • updateHandleSyncEvent
  • updateHandleInboundEvent
  • updateHandleMessageEvent

It's recommended that you ensure requests are coming from Mailchimp Transactional rather than an imitator. Webhook authentication is disabled by default but you can enable webhook authentication through the config layer like so:

LeKoala\Mandrill\MandrillController:
  webhook_auth_enabled: true

You'll need your webhook authentication key which you can view and reset from the (Webhooks)[https://mandrillapp.com/settings/webhooks] page in your account. Add your key using the config layer or .env file.

via config

LeKoala\Mandrill\MandrillController:
  webhook_key: YOUR_KEY

via .env file

MANDRILL_WEBHOOK_KEY=YOUR_KEY

Migration from Swift Mailer

SilverStripe 5 replaced swift mailer by symfony/mailer

Make sure to read the docs https://docs.silverstripe.org/en/5/developer_guides/email/ https://symfony.com/doc/current/mailer.html

For SS4 version, check branch 3 and v4 releases

Compatibility

Tested with SilverStripe 5+

Maintainer

LeKoala - [email protected]

silverstripe-mandrill's People

Contributors

camfindlay avatar djmattski avatar lekoala avatar linkdup avatar philbenoit avatar rsmclaren avatar tomzi avatar tractorcow avatar wilr avatar zanderwar avatar zarocknz avatar

Stargazers

 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

silverstripe-mandrill's Issues

License unclear.

Hello lekoala,

the composer.json says BSD, the file says MIT. Which one is accurate?

Cheers,
Peter

Unable to attach file from MandrillEmail::sendTemplate()

Hey, I'm might be looking at this incorrectly but im trying to attach a file while using the sendTemplate function. (I don't need the GUI just the functionality)

$mailer = MandrillEmail::create();
$mailer->setTo($to);
$mailer->setRecipientMetadatas($to, []);
$mailer->setFrom('[email protected]');
$mailer->setSubject($subject);

$file = '/home/user/public_html/myfile.png';
$mailer->attachFile($file); // this doesn't work. It doesn't appear to call the encodeFileForEmail anywhere thats within `MandrillMailer`

$mailer->sendTemplate(
    'application-approval',
    $mergeVars
);

The email is sent successfully but no file is attached

Emails not coming into model admin

hello

I have maindrill set up emails are being sent from the server, but it isn't being pulled into the Admin in the CMS.

Any advice on getting this working?

I am running Silverstripe 4

Thanks

Unable to send forgot password email

Unable to send the email with default SS forgot password form.
This is in the error logs
PHP Fatal error: Cannot access self:: when no class scope is active in /silverstripe-mandrill-master/code/MandrillEmail.php on line 908

PHP 7.2 compatibility for version 2.0.0

SilverStripe 3.7.0 enabled PHP 7.2 support, but the 2.0.0 version of this plugin has references to Object, which is now a restricted keyword in PHP.

Is it possible for you to add a

if (!class_exists('SS_Object')) class_alias('Object', 'SS_Object');

check into the _config.php of the 2.0.0 version of this module?

Sub accounts can see other sub accounts activity.

When using the sub accounts feature there is a bit of a privacy issue in the modal admin.
Any sub account can see the activity of another sub account using the same API key.

I have created a pull request to fix this issue by creating a new private mode but I thought I would still post here incase anyone else was wanting to use this module in this way.

Add some version tags

Great module, if you are starting to add new things it might be good to start thinking about tagging stable versions rather than having everyone use dev-master ๐Ÿ‘

How do you use this?

After declaring the api key, do you go ahead and use the normal silverstripe mailing system? and can you define the api key in _config.php other than _ss_environment.php?

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.