Giter Site home page Giter Site logo

messages's Introduction

Swift Mailer Laravel Bundle

The power of Swift Mailer with the beauty of Laravel.

Installation

Install using the Artian CLI:

php artisan bundle:install messages

then edit application/bundles.php to autoload messages:

<?php

return array(

'messages' => array(
	'auto' => true
),

You can then set your configuration at config/config.php.

A Few Examples

Changing configurations in runtime

<?php

Config::set('messages::config.transports.smtp.host', 'smtp.gmail.com');
Config::set('messages::config.transports.smtp.port', 465);
Config::set('messages::config.transports.smtp.username', '[email protected]');
Config::set('messages::config.transports.smtp.password', 'password');
Config::set('messages::config.transports.smtp.encryption', 'ssl');

Sending a message:

<?php

Message::to('[email protected]')
	->from('[email protected]', 'Bob Marley')
	->subject('Hello!')
	->body('Well hello Someone, how is it going?')
	->send();

Checking if the message was sent

<?php

$message = Message::to('[email protected]')
			->from('[email protected]', 'Bob Marley')
			->subject('Hello!')
			->body('Well hello Someone, how is it going?')
			->send();

if($message->was_sent())
{
	echo 'Sweet it worked!';
}

// Or:
if(Message::was_sent())
{
	echo 'Sweet it worked!';
}

Checking if a specific email received the message

<?php

$message = Message::to('[email protected]')
			->from('[email protected]', 'Bob Marley')
			->subject('Hello!')
			->body('Well hello Someone, how is it going?')
			->send();

if($message->was_sent('[email protected]'))
{
	echo 'Sweet, Someone got the email!';
}

Sending an email with an attachment

<?php

Message::to('[email protected]')
	->from('[email protected]')
	->subject('Hello!')
	->body('Well hello Someone, how is it going?')
	->attach('/path/to/file.txt')
	->send();

Sending an email with HTML

<?php

Message::to('[email protected]')
	->from('[email protected]')
	->subject('Hello!')
	->body('Well hello <b>Someone</b>, how is it going?')
	->html(true)
	->send();

Sending emails to multiple email addresses

<?php

Message::to(array('[email protected]', '[email protected]' => 'name'))
	->cc('[email protected]')
	->bcc(array('[email protected]' => 'Another name', '[email protected]'))
	->subject('Hello Guys!')
	->body('I really like spamming people!')
	->send(); 

Sending an email with a reply address

<?php

Message::to('[email protected]')
	->from('[email protected]')
	->reply('[email protected]')
	->subject('Hello!')
	->body('Well hello <b>Someone</b>, how is it going?')
	->html(true)
	->send();

Swift Mailer, by Chris Corbyn

Swift Mailer is a component based mailing solution for PHP 5. It is released under the LGPL license.

Swift Mailer is highly object-oriented by design and lends itself to use in complex web application with a great deal of flexibility.

For full details on usage, see the documentation.

messages's People

Contributors

loic-sharma avatar akhy avatar brettteasdale avatar ivannpaz avatar msurguy avatar sineld avatar lavaeagle avatar

Watchers

Brett Teasdale avatar

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.