Git Product home page Git Product logo

mandrillbundle's Introduction

SlotMandrillBundle

Build Status

Send transactional mail through mandrill.com. This bundle provides an easy api for Symfony2 Projects.

All settings inside message class represent attributes of Mandrill's API. Please refer to their API documentation for Details:

https://mandrillapp.com/api/docs/messages.html

Prerequisites

Before you're able to use this bundle you must sign up with Mandrill.

http://mandrill.com

Mandrill is a great way to send your transactional emails and provides detailed advances reports.

Mandrill is free for limited number of email per day, please read through pricing section on the website for more information:

http://mandrill.com/pricing/

Installation

via composer:

composer require slot/mandrill-bundle

Enable the bundle in the kernel

<?php
// app/AppKernel.php

public function registerBundles()
{
    $bundles = array(
        // ...
        new Slot\MandrillBundle\SlotMandrillBundle(),
    );
}

Configuration

Add configuration to config.yml.

Log in to Mandrill and go to "Settings" -> "SMTP and API Credentials". Create an API Key and use it in your Symfony2 Configuration.

# config.yml

slot_mandrill:
    api_key: xxxxx
    disable_delivery: true # useful for dev/test environment. Default value is 'false'
    # debug: passed to \Mandrill causing it to output curl requests. Useful to see output
    # from CLI script. Default value is 'false'
    debug: true
    default:
        sender: [email protected]
        sender_name: John Doe # Optionally define a sender name (from name)
        subaccount: Project # Optionally define a subaccount to use
    proxy:
        use: true # when you are behing a proxy. Default value is 'false'
        host: example.com
        port: 80
        user: john
        password: doe123

Now you're all set, send your first transactional mails:

Use

Simple controller Example:

<?php

// src/Slot/ExampleBundle/Controller/ExampleController.php
namespace Slot\ExampleBundle\Controller;

use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\HttpFoundation\Response;
use Slot\MandrillBundle\Message;
use Slot\MandrillBundle\Dispatcher;

class ExampleController extends Controller
{
    public function indexAction()
    {
        $dispatcher = $this->get('slot_mandrill.dispatcher');

        $message = new Message();

        $message
            ->setFromEmail('[email protected]')
            ->setFromName('Customer Care')
            ->addTo('[email protected]')
            ->setSubject('Some Subject')
            ->setHtml('<html><body><h1>Some Content</h1></body></html>')
            ->setSubaccount('Project');

        $result = $dispatcher->send($message);

        return new Response('<pre>' . print_r($result, true) . '</pre>');

    }

}

Using Handlebars

By default the bundle will assume the merge language is 'mailchimp'. You can change this with $message->setMergeLanguage('handlebars')

mandrillbundle's People

Contributors

ariful-khan avatar bonswouar avatar crmpicco avatar fesja avatar geoffreytran avatar jit-ci[bot] avatar johjohan avatar maxime-pasquier avatar mrafalkoitr avatar nainterceptor avatar nicolasbadey avatar oskarstark avatar pierstoval avatar redthor avatar rickpastoor avatar ruudk avatar simonchrz avatar slot avatar tautelis avatar tobiassjosten avatar ukwm-deploy avatar wcoppens avatar wodka 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

Watchers

 avatar  avatar  avatar  avatar

mandrillbundle's Issues

Cant install on Symfony 2.8 LTS

Hi,

I cant install this bundle now on LTS version of Symfony as symfony/config and symfony/http-foundation must be >= 3.0

Is it possible to have them like "symfony/config":"~2.8|~3.0", "symfony/http-foundation":"~2.8|~3.0" it seems to not break anything?

Thanks,
Milosz

Are merge vars possible?

Hey there, I had a quick poke around in the code after digging through the docs but could not see any reference to merge variables.

The link to mandrill references the json section.

Is it just a case of swapping mandrill's api calls from underscore to camelcase to use this pluggin?

eg:

->setGlobalMergeVars( array(
            array(
                'name' => 'merge1',
                'content' => 'merge1 content'
            )
        ) )

Cheers,
John

email sent and then the process gets killed

Hi there,

This appears to be an intermittent issue for us, which is utterly annoying. Our code looks like this:

$this->logger->info('prepare to send the email');
$result = $this->mailer->send();
$this->logger->info('email has been sent: ', array('result' => $result));

Being intermittent, I mean sometimes you see both log entries and emails are sent, but sometimes, the process hangs after sending the email. So the email is delivered, but you don't see the last log with the result returned from Mandrill api.

I've been pulling my hairs for weeks on this issue and really don't know what's going on. However, whenever the process hangs, there's this error message on the error log.

[fastcgi:error] [pid 19323] (104)Connection reset by peer: [client xx.xx.xx.xx] FastCGI: comm with server "/usr/lib/cgi-bin/php5-fcgi" aborted: read failed

We are using Apache + PHP-FPM. I tried to life the memory_limit, but didn't work out, and there's never a memory being exhausted message in the server log, so I doubt it's the memory issue. No errors on php5-fpm log as well.

Any ideas would be appreciated.

Installing Version 1.1 requires symfony/config >= 3.0

Hello.

I have recently an error trying to download the bundle.
Just yesterday a member of my team downloaded without problem. Now, I'm trying to download with symfony's version 2.8 and there exists the error.

There's no more support to older versions of Symfony?
I don't going to move my project to symfony's 3.0 version.

How you can help us???

Cheers and thanks.
Jaime.

addMergeVars and handlebars problem with loop

I've a problem using "addMergeVars" adding an array for a variable:

$playlists = [
         ['channel'=>'UC7HDT4RR9sXmuuEqClX_05w', 'cname'=>'channel1'],
         ['channel'=>'UCsT0YIqwnpJCM-mx7-gSA4Q', 'cname'=>'channel2']
        ]; 
...
$message->addTo($email,$firstname)
            ->addMergeVars($email, [
                [ 'name'  => 'fname',  'content' => $firstname],
                [ 'name'  => 'playlists',  'content' =>  $playlists],
            ]);

the handlebars template on mandrill is something like:

{{fname}}<br/>

{{#each playlists}}
      channel: {{channel}} 
 {{/each}}

now.. {{fname}} is parsed correctly, but the loop fails, it doesn't render anything.
I need some help

Method signature change.

After update to new version i am getting this error due to signature change.

Warning: Missing argument 7 for Hip\MandrillBundle\Dispatcher::__construct(), called in /home/ariful1/imoney/formapply/src/app.php on line 336 and defined.

Adding top level signature change should handle properly.

Will this package be upgraded to remove the abandoned mandrill/mandrill dependency?

Apologies, I seem to have inadvertently broken this package with my commit.

I have tried to switch to dev-master in my application, but it is badly broken.

It seems there are a few places where this package needs updated to support mandrill/transactional instead of the mandrill/mandrill package which is now abandoned.

Are there any plans for the maintainers to upgrade this package or is the slot/MandrillBundle all but abandoned?

Package does not work with mailchimp/transactional

The deprecated mandrilll/mandrill dependency was replaced with mailchimp/transactional, but the package will not work simply by changing the client class to be used, since the interface is significantly different.

Using Multiple Mailers with Mandrill

I ude hipaway-travel/mandrill-bundle for one account, but have two accounts in mandrill and how usage two accounts ?
I look about swiftmailer but not understand how to correct config

swiftmailer:
default_mailer: default
mailers:
  default
      transport: "%mailer_transport%"
      host:      "%mailer_host%"
      username:  "%mailer_user%"
      password:  "%mailer_password%"
      spool:     { type: memory }
  reserve
      transport: "%mailer_transport1%"
      host:      "%mailer_host1%"
      username:  "%mailer_user1%"
      password:  "%mailer_password1%"
      spool:     { type: memory }

this my mandril config

hip_mandrill:
api_key: %mailer_password%
disable_delivery: false
default:
    sender: [email protected]
    sender_name: Name

now when I need send email I get mandril service like:

        $dispatcher = $this->get('hip_mandrill.dispatcher');

    $parameters = [
        'test1' => $project,
        'test2' => $user,
    ];

    $message = new Message();

    $message->setFromEmail($this->emailFrom_nr)
        ->setFromName($this->emailAuthorName_nr)
        ->addTo($email))
        ->setSubject('Subject')
        ->setHtml($this->get('twig')->render('MyBundle:Mail:test.html.twig', $parameters));

    $result = $dispatcher->send($message);

    return $result;

how to apply Multiple Mailers for mandril ? help

SSL certificate problem (curl problem i think)

please, some info about how to solve:

 API call to messages/send failed: SSL certificate problem: unable to get local issuer certificate

I'm not using proxy, I'm almost sure that this problem is related to the test env. but any help is welcome.

Bundle configuration error

Hi all,

Simple problems come with simple solution (in this case) !

In the bundle, path : "/ProjectName/vendor/hipaway-travel/mandrill-bundle/Hip/MandrillBundle/Resources/config/services.yml"

Please consider add some double quotes on the "@hip_mandrill.client" argument so people could use this awesome bundle without updating it.

Thanks !

Set a default for trackClicks

Is it possible to set a global default for trackClicks? I'd like it to be FLASE but it looks like it's hard coded to be a default of TRUE. I know I can change this on a per-message basis, I was just wondering if there was a way to do it globally.

API returns empty array

Hello,

I did exactly everything what was in the readme file but when I call the ->send method I get an empty array and no email is sent.

Any idea what is the problem? I don't even see anything in the logs.

BTW: When I use the mandrill API manually only with curl, it works.

If you need more details, please tell me but the code I used is basically the readme file (USE part)

Do not send emails in dev/test environments

Hi,

I think it would be very nice to use disable_delivery setting to not send email in debug mode as it done for SwiftMailer .

If you will accept PR, I can implement this. What do you think?

Sending of mails sometimes takes a lot of time

Hi,

Before getting into the issue, thanks for creating the bundle!
I'm using this bundle to send like 15000 emails a month.
Some mail messages take up to 5 seconds to sent with our CPU at a 100% usage.
I have investigated it quite a bit thinking it was our code (and it still could be) but i think it's the toArray() call on the Message object causing this. (Message.php:843 called from Dispatcher.php:122)

The Mandrill API logs tell us that the API calls have an execution time of 20 to 400ms so it's probably not the HTTP connection having any trouble since the PHP process is running at 100% CPU and the HTTPD process isn't having much issues.

Could you share your opinion on this?

Thanks in advance,
Maarten Sprakel

Message defaults

The more I use this bundle, the more I think that the defaults should be set to null, rather than true or false.

This way it takes on the account defaults, and the user can override as needed.

idea to help dev/debug

First of all: awesome bundle!

it would be nice to have an option to set a "delivery_address" that could be used in dev env, it would overwrite any TO address and set the default one.

Send at

Would be nice to implement the $send_at parameter to the send method.

(and at the same time $ip_pool I guess)

Tags please

I want to use the bundle but I'm a bit afraid because you don't have any tags.

Please create a tag and follow the http://semver.org/ standard

$this->merge is false when mergeTags provided

Set merge says "Will automatically be set to true if either merge_vars or global_merge_vars are provided."

However I can see no where this happens.

I was trying to solve it by checking in getMerge(), however toArray() grabs the values out of the properties directly.

The other way, is on set merge to true in addGlobalMergeVar(), addMergeVar() and addMergeVars()

When v1.3?

Hey, since mandrill/mandrill is not used anymore and we have mailchimp/transactional dependency in master already, are we expecting v1.3?
For now it makes us lock dev-master#f77e27bb966d6bb5f71cd17d7d2b24e67c7143fc to have last changes onboard. And obviously it's not the right way.
Any updates appreciated.

Thanks.

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.