-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rename pluging to wordpress-mailer-dsn
- Loading branch information
1 parent
8cd7ecc
commit 94b7dcd
Showing
5 changed files
with
43 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,22 @@ | ||
# WordPress Mail URL | ||
# WordPress Mailer DSN | ||
|
||
[![CI](https://github.com/voronkovich/wordpress-mail-url/actions/workflows/ci.yml/badge.svg)](https://github.com/voronkovich/wordpress-mail-url/actions/workflows/ci.yml) | ||
[![CI](https://github.com/voronkovich/wordpress-mailer-dsn/actions/workflows/ci.yml/badge.svg)](https://github.com/voronkovich/wordpress-mailer-dsn/actions/workflows/ci.yml) | ||
|
||
[WordPress](https://wordpress.org/) plugin to configure [wp_mail()](https://developer.wordpress.org/reference/functions/wp_mail/) via `MAIL_URL` environment variable. | ||
[WordPress](https://wordpress.org/) plugin to configure [wp_mail()](https://developer.wordpress.org/reference/functions/wp_mail/) via `MAILER_DSN` environment variable. | ||
|
||
## Installation | ||
|
||
Use the [Composer](https://getcomposer.org/): | ||
|
||
```sh | ||
composer require voronkovich/wordpress-mail-url | ||
composer require voronkovich/wordpress-mailer-dsn | ||
``` | ||
|
||
Don't forget to activate the plugin, if you don't use the `mu-plugins` directory. | ||
|
||
Define (in your `.env` file for example) the `MAIL_URL` variable like this: | ||
Define (in your `.env` file for example) the `MAILER_DSN` variable like this: | ||
```sh | ||
MAIL_URL='mail://localhost' | ||
MAILER_DSN='mail://localhost' | ||
``` | ||
|
||
## Configuraton | ||
|
@@ -32,7 +32,7 @@ Supported protocols: | |
Additional configuration could be applied via query string: | ||
|
||
```sh | ||
MAIL_URL='mail://localhost?XMailer=SuperMailer&FromName=CoolSite' | ||
MAILER_DSN='mail://localhost?XMailer=SuperMailer&FromName=CoolSite' | ||
``` | ||
|
||
[PHPMailer](https://github.com/PHPMailer/PHPMailer) configured by public properties, so you can use any of them. All allowed options could be found at [PHPMailer Docs](https://phpmailer.github.io/PHPMailer/classes/PHPMailer-PHPMailer-PHPMailer.html#toc-properties). | ||
|
@@ -41,17 +41,17 @@ MAIL_URL='mail://localhost?XMailer=SuperMailer&FromName=CoolSite' | |
|
||
### Sendmail | ||
```sh | ||
MAIL_URL='sendmail://localhost?Sendmail=/usr/sbin/sendmail%20-oi%20-t' | ||
MAILER_DSN='sendmail://localhost?Sendmail=/usr/sbin/sendmail%20-oi%20-t' | ||
``` | ||
|
||
### SMTP | ||
```sh | ||
MAIL_URL='smtp://user@password@localhost?SMTPDebug=3&Timeout=1000' | ||
MAILER_DSN='smtp://user@password@localhost?SMTPDebug=3&Timeout=1000' | ||
``` | ||
|
||
### Gmail | ||
```sh | ||
MAIL_URL='smtps://[email protected]:[email protected]?SMTPDebug=3' | ||
MAILER_DSN='smtps://[email protected]:[email protected]?SMTPDebug=3' | ||
``` | ||
|
||
## License | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,12 @@ | ||
<?php | ||
|
||
/** | ||
* Plugin Name: Mail URL | ||
* Plugin URI: https://github.com/voronkovich/wordpress-mail-url | ||
* Description: Configure wp_mail() via MAIL_URL environment variable | ||
* Plugin Name: Mailer DSN | ||
* Plugin URI: https://github.com/voronkovich/wordpress-mailer-dsn | ||
* Description: Configure wp_mail() via MAILER_DSN environment variable | ||
* Version: 0.0.2 | ||
* License: MIT | ||
* License URI: https://github.com/voronkovich/wordpress-mail-url/blob/main/LICENSE | ||
* License URI: https://github.com/voronkovich/wordpress-mailer-dsn/blob/main/LICENSE | ||
* Author: Oleg Voronkovich <[email protected]> | ||
* Author URI: https://github.com/voronkovich | ||
*/ | ||
|
@@ -16,5 +16,5 @@ | |
add_action('phpmailer_init', function ($phpmailer) { | ||
require_once __DIR__ . '/functions.php'; | ||
|
||
\mailurl_phpmailer_init($phpmailer); | ||
\mailerdsn_phpmailer_init($phpmailer); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,51 +14,51 @@ | |
/** | ||
* @coversNothing | ||
*/ | ||
class MailUrlTest extends TestCase | ||
class MailerDsnTest extends TestCase | ||
{ | ||
public function testThrowsExceptionIfUrlIsMailformed() | ||
public function testThrowsExceptionIfDsnIsMailformed() | ||
{ | ||
\putenv('MAIL_URL=localhost'); | ||
\putenv('MAILER_DSN=localhost'); | ||
|
||
$this->expectException(\RuntimeException::class); | ||
$this->expectExceptionMessage('Mailformed mail URL: "localhost".'); | ||
|
||
$phpmailer = new PHPMailer(true); | ||
|
||
\mailurl_phpmailer_init($phpmailer); | ||
\mailerdsn_phpmailer_init($phpmailer); | ||
} | ||
|
||
public function testThrowsExceptionIfUrHasInvalidScheme() | ||
public function testThrowsExceptionIfDsnHasInvalidScheme() | ||
{ | ||
\putenv('MAIL_URL=ftp://localhost'); | ||
\putenv('MAILER_DSN=ftp://localhost'); | ||
|
||
$this->expectException(\RuntimeException::class); | ||
$this->expectExceptionMessage('Invalid mail URL scheme: "ftp"'); | ||
|
||
$phpmailer = new PHPMailer(true); | ||
|
||
\mailurl_phpmailer_init($phpmailer); | ||
\mailerdsn_phpmailer_init($phpmailer); | ||
} | ||
|
||
public function testThrowsExceptionIfUrHasInvalidOption() | ||
public function testThrowsExceptionIfDsnHasInvalidOption() | ||
{ | ||
\putenv('MAIL_URL=mail://localhost?Helo=Hi&Unknown=Invalid'); | ||
\putenv('MAILER_DSN=mail://localhost?Helo=Hi&Unknown=Invalid'); | ||
|
||
$this->expectException(\RuntimeException::class); | ||
$this->expectExceptionMessage('Unknown mail URL option: "Unknown"'); | ||
|
||
$phpmailer = new PHPMailer(true); | ||
|
||
\mailurl_phpmailer_init($phpmailer); | ||
\mailerdsn_phpmailer_init($phpmailer); | ||
} | ||
|
||
public function testConfiguresPHPMailerWithProvidedByUrlSettings() | ||
public function testConfiguresPHPMailerWithProvidedByDsnSettings() | ||
{ | ||
\putenv('MAIL_URL=smtps://[email protected]:[email protected]?SMTPDebug=3&Timeout=60'); | ||
\putenv('MAILER_DSN=smtps://[email protected]:[email protected]?SMTPDebug=3&Timeout=60'); | ||
|
||
$phpmailer = new PHPMailer(true); | ||
|
||
\mailurl_phpmailer_init($phpmailer); | ||
\mailerdsn_phpmailer_init($phpmailer); | ||
|
||
$this->assertEquals($phpmailer->Mailer, 'smtp'); | ||
$this->assertEquals($phpmailer->Host, 'smtp.gmail.com'); | ||
|