Git Product home page Git Product logo

mymail's Introduction

Dframe/MyMail

Build Status Latest Stable Version Latest Unstable Version License

Simple mail wrapper using phpmailer

Composer

$ composer require dframe/mymail

Usage

Standalone example#1 php

use \Dframe\MyMail\MyMail;

require_once __DIR__ . '/../vendor/autoload.php';
$config = require_once 'config/config.php'; 
$MyMail = new MyMail($config);                                       // Load Config
$addAddress = ['mail' => 'adres@email', 'name' => 'Title From']; // Addresses to send
$MyMail->send($addAddress, 'Test Mail', $body);
Standalone example#2 php
<?php

use Dframe\MyMail\MyMail;

require_once __DIR__ . '/../vendor/autoload.php';
$config = require_once 'config/config.php'; 

$MyMail = new MyMail($config); // Załadowanie Configu
$MyMail->mail->isSMTP();
$MyMail->mail->SMTPOptions = array(
    'ssl' => array(
        'verify_peer' => false,
        'verify_peer_name' => false,
        'allow_self_signed' => true
    )
);
//$MyMail->SMTPDebug  = 2; // Enables SMTP debug information (for testing)
                         // 1 = errors and messages
                         // 2 = messages only
$MyMail->mail->SMTPSecure = false;

$addAddress = ['mail' => 'adres@email', 'name' => 'titleFrom']; // Addresses to send

try {
    $MyMail->send($addAddress, 'Test Mail', 'Hello Word!');

} catch (Exception $e) {
    echo $e->getMessage();
	
}

Example #1 with Dframe Framework

config/myMail.php - here

<?php

use Dframe\MyMail\MyMail;
use Dframe\Component\Config\Config;
$view = $this->loadView('index');
$MyMail = new MyMail(Config::load('myMail')->get()); // Load Configu

/* 
 * If you have problem with ssl in php 5.6 add
 *       $MyMail->SMTPOptions = [
 *           'ssl' => [
 *               'verify_peer' => false,
 *               'verify_peer_name' => false,
 *               'allow_self_signed' => true
 *           ]
 *       ];
 */
 
 $MyMail->SMTPDebug  = 2; // Enables SMTP debug information (for testing)
                          // 1 = errors and messages
                          // 2 = messages only
		       
$addAddress = ['mail' => $_POST['email'], 'name' => $_POST['firstname']];    // Addresses to send
$view->assign('name', $_POST['firstname']);                                       // Assign template values
$body = $view->fetch('reset');                                                    // Template mail
$MyMail->send($addAddress, 'Test Mail', $body);

mymail's People

Contributors

dusta avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

amadeuszxd

mymail's Issues

Bugfix typo

before

$config['CharSet']

after

$config['charSet'];

camelCase Config

Before

<?php

return [
    'Hosts' => ['primaryHostName.tld', 'backupHostName.tld'],    // Specify main and backup SMTP servers
    'SMTPAuth' => true,    // Enable SMTP authentication
    'Username' => 'Username@mail',    // SMTP username
    'Password' => '',    // SMTP password
    'SMTPSecure' => 'tls',    // Enable TLS encryption, `ssl` also accepted
    'Port' => 587,    // Port

    'SenderName' => PROJECT_NAME,    //Name of default sender
    'SenderEmail' => 'senderMail@mail'    //Default sender's address
];

After

<?php

return [
    /**
     * Specify main and backup SMTP servers
     */
    'hosts' => ['primaryHostName.tld', 'backupHostName.tld'],

    /**
     * Enable SMTP authentication
     */
    'smtpAuth' => true,

    /**
     * SMTP username
     */
    'username' => 'Username@mail',

    /**
     * SMTP password
     */
    'password' => '',

    /**
     * Enable TLS encryption, `ssl` also accepted
     */
    'smtpSecure' => 'tls',

    /**
     * Port
     */
    'port' => 587,

    /**
     * Name of default sender
     */
    'senderName' => PROJECT_NAME,

    /**
     * Default sender's address
     */
    'senderEmail' => 'senderMail@mail'
];

Undefined addAttachment

Undefined addAttachment

src/MyMail.php

  if (!empty($this->addAttachment)) {
            foreach ($addAttachment as $key => $attachment) {
                $this->mailObject->addAttachment = $attachment;
            }
        }
  }

Should be

  if (!empty($this->addAttachment)) {
            foreach ($this->addAttachment as $key => $attachment) {
                $this->mailObject->addAttachment = $attachment;
            }
        }
  }

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.