Skip to content

fivesqrd/fluent-musimal-php

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Musimal for PHP

This library is based on the open source Musimal responsive HTML email design and uses Fluent for PHP to elegantly construct an responsive email body with code instead of HTML markup.

Sample Email Layout

Below is a sample of the Musimal email design and the various UI components Layout

Install

composer require fivesqrd/fluent-musimal fivesqrd/fluent-client

Config

Certain aspects of the look can be customised by presetting some config parameters:

$options = array(
    'logo'          => 'My App', //Plain text or publicly available URL. Image not wider than 200px
    'color'         => '#ff6600', //Primary colour
    'footer'        => 'My test generated by Musimal for PHP', //Text at bottom of all messages
);

Quick Example

Create a responsive HTML message body:

/* Construct a message body using the Fluent Client */
$body = (new Fluent\Body())
    ->title('My little pony')
    ->paragraph('Lorem ipsum dolor sit amet, consectetur adipiscing elit.')
    ->number(['caption' => 'Today', value => date('j M Y')])
    ->button('http://www.mypony.com', 'Like my pony')
    ->paragraph('Pellentesque habitant morbi tristique senectus et netus et malesuada fames.');

/* Render the body to an HTML document */
$html = (new Fluent\Layout($options))->render($body);

Sending with Fluent Web Service

Delivering the the message with Fluent for PHP. Rendering will be done server side, so the body object can be passed as is:

$body = (new Fluent\Body())
    ->title('My little pony')
    ->paragraph('Lorem ipsum dolor sit amet, consectetur adipiscing elit.')
    ->number(['caption' => 'Today', value => date('j M Y')])
    ->button('http://www.mypony.com', 'Like my pony')
    ->paragraph('Pellentesque habitant morbi tristique senectus et netus et malesuada fames.');

$messageId = (new Fluent\Delivery($config))->create()
    ->content($body)
    ->subject('Testing it')
    ->from('[email protected]', 'My App')
    ->to('[email protected]')
    ->send();

Sending with mail()

Sending the message in PHP

$body = (new Fluent\Body())
    ->title('My little pony')
    ->paragraph('Lorem ipsum dolor sit amet, consectetur adipiscing elit.')
    ->number(['caption' => 'Today', value => date('j M Y')])
    ->button('http://www.mypony.com', 'Like my pony')
    ->paragraph('Pellentesque habitant morbi tristique senectus et netus et malesuada fames.');

/* Render the body to an HTML document */
$html = (new Fluent\Layout($options))->render($body);

$headers = [
    'MIME-Version: 1.0',
    'Content-type: text/html; charset=iso-8859-1'
];

mail($to, $subject, $html, implode("\r\n", $headers));

Releases

No releases published

Packages

No packages published

Languages