starring-jane/wordplate-mail

Adds mail settings to your environment configuration

1.0.4 2023-05-08 11:52 UTC

This package is auto-updated.

Last update: 2024-04-08 13:40:51 UTC


README

Starring Jane

Wordplate Mail

Adds mail settings to your environment configuration

Installation

composer require starring-jane/wordplate-mail

Create a WordplateMail instance in functions.php

use StarringJane\WordplateMail\WordplateMail;

WordplateMail::register();

Usage

Add your smtp settings to your .env file

MAIL_DRIVER=smtp
MAIL_HOST=localhost
MAIL_PORT=465
MAIL_USERNAME=user
MAIL_PASSWORD=pass
MAIL_ENCRYPTION=tls
MAIL_FROM_NAME="Sender Name"
MAIL_FROM_ADDRESS="no-reply@domain.com"

You can also send trough the local mail driver

MAIL_DRIVER=mail
MAIL_HOST=localhost
MAIL_PORT=25
MAIL_USERNAME=null
MAIL_PASSWORD=null
MAIL_ENCRYPTION=null
MAIL_FROM_NAME="Sender Name"
MAIL_FROM_ADDRESS="no-reply@domain.com"

Override variables in code

Sometimes you might want to set variables dynamicaly

use StarringJane\WordplateMail\WordplateMail;

WordplateMail::register()
    ->set('MAIL_FROM_NAME', 'Starring Jane')
    ->set('MAIL_FROM_ADDRESS', function () {
        $domain = str_replace('www.', '', $_SERVER['SERVER_NAME']);
        return 'no-reply@' . $domain;
    });

Contributors

Credits

Special thanks to the contributors of wordplate for allowing us to create Wordpress websites in a modern development environment