PHP code example of instaclick / base-mail-bundle

1. Go to this page and download the library: Download instaclick/base-mail-bundle library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

instaclick / base-mail-bundle example snippets


    // application/ApplicationKernel.php
    public function registerBundles()
    {
        // ...
        $bundles[] = new IC\Bundle\Base\MailBundle\ICBaseMailBundle();
    
        return $bundles;
    }
    

$composerService = $this->getContainer()->get('ic_base_mail.service.composer');
$message         = $composerService->createMessage();

interface MessageInterface
{
    /**
     * Get the subject.
     *
     * @return string
     */
    public function getSubject();

    /**
     * Set the subject.
     *
     * @param string $subject
     */
    public function setSubject($subject);

    /**
     * Get the recipient.
     *
     * @return string
     */
    public function getRecipient();

    /**
     * Set the recipient.
     *
     * @param string $recipient
     */
    public function setRecipient($recipient);

    /**
     * Get the senderName.
     *
     * @return string
     */
    public function getSenderName();

    /**
     * Set the senderName.
     *
     * @param string $senderName
     */
    public function setSenderName($senderName);

    /**
     * Get the senderAddress.
     *
     * @return string
     */
    public function getSenderAddress();

    /**
     * Set the senderAddress.
     *
     * @param string $senderAddress
     */
    public function setSenderAddress($senderAddress);

    /**
     * Get the sender (as a composite value of name and address)
     *
     * @return array
     */
    public function getSender();

    /**
     * Get the replyTo address.
     *
     * @return array
     */
    public function getReplyTo();

    /**
     * Set the repylTo address.
     *
     * @param string $replyTo
     */
    public function setReplyTo($replyTo);

    /**
     * Get the returnPath.
     *
     * @return array
     */
    public function getReturnPath();

    /**
     * Set the returnPath.
     *
     * @param string $returnPath
     */
    public function setReturnPath($returnPath);

    /**
     * Get the templateName.
     *
     * @return string
     */
    public function getTemplateName();

    /**
     * Set the templateName.
     *
     * @param string $templateName
     */
    public function setTemplateName($templateName);

    /**
     * Get the parameterList.
     *
     * @return array
     */
    public function getParameterList();

    /**
     * Set the parameterList.
     *
     * @param array $parameterList
     */
    public function setParameterList(array $parameterList = array());

    /**
     * Get the contentType.
     *
     * @return string
     */
    public function getContentType();

    /**
     * Set the contentType.
     *
     * @param string $contentType
     */
    public function setContentType($contentType);

    /**
     * Check if this message is usable.
     *
     * @return boolean
     */
    public function isUsable();
}

// ...
$composerService = $this->getContainer()->get('ic_base_mail.service.composer');
$senderService   = $this->getContainer()->get('ic_base_mail.service.sender');

$message = $composerService->createMessage();

$message->setSubject('Email Delivery Service');
$message->setRecipient('[email protected]');
$message->setTemplateName('ICCoreSiteBundle:EmailTemplates:welcome.html.twig');
$message->setParameterList(array('username' => 'Guilherme Blanco'));

$sentSuccessfully = $senderService->send($message);