https://github.com/phore/phore-mail
Sending mails using text-template
https://github.com/phore/phore-mail
Last synced: 5 months ago
JSON representation
Sending mails using text-template
- Host: GitHub
- URL: https://github.com/phore/phore-mail
- Owner: phore
- License: mit
- Created: 2018-07-25T09:17:49.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2023-06-26T17:26:46.000Z (almost 3 years ago)
- Last Synced: 2025-11-02T19:15:55.108Z (8 months ago)
- Language: Shell
- Homepage: https://infracamp.org/phore/
- Size: 30.3 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Phore Mail
A template wrapper around the famous *[PHPMailer](https://github.com/PHPMailer/PHPMailer)*
Mailer class and the *[text/template](https://github.com/dermatthes/text-template)* template system.
- Single Class
- Multipart Mime
- Testing using [mailtrap.io](https://mailtrap.io)
## Demo template
```
{mail to="abc@abc.de" name="Some Name"}
{mail from="sender@address.de" name="Me"}
{mail cc="mail@email" name="Some Name"}
{mail bcc="mail@email" name="Some Name"}
{subject}Hello {=name} - You are the welcome{/subject}
{html}
Hello {= name},
This HTML Mime Mail
{/html}
Hello {= name},
This is the alternative Text body
```
## Available mail parameters
| Parameter | Name | Default |
|-----------|------|---------|
| `charset` | |
| `to` ||
| `from` ||
| `cc` ||
| `bcc` ||
## Script for sending a mail
With auto-failover to second SMTP-Server.
```php
$mailer = new PhoreMailer();
$mailer->config([
"Host" => "smtp1.example.org;smtp2.example.org",
"Username" => "user@example.org",
"Password" => "secret",
"SMTPAuth" => true
]);
$mailer->send($templateText, ["name"=>"Joe Doe"]);
```
## Installation
```
composer require phore/mail
```
## Configuring PHPMailer / text-template
```php
$mailer = new PhoreMailer();
$mailer->phpmailer->phpMailerFunction();
```
```php
$mailer = new PhoreMailer();
$mailer->textTemplate->textTemplateFunction();
```
## Sending mail without mailserver using SMTP
> This method is for testing only. Most Mailservers will
> reject mail transferred with this method.
```
```
## Demos
- [Basic/simple template sending mail](docs/simple-demo.php)
- [SMTP Auth](docs/smtp-auth-demo.php)
- [Setting charset](docs/setting-charset.php)
## Debugging
Instead of sending the mail, you can retrieve the PHPMailer
instance by calling `prepare()`.
```
$phpmail = $phoreMailer->prepare($template,[]);
print_r ($phpmail);
$phpmail->Send();
```
## Intercepting outgoing mail
```php
$mailer->setSendMailFunction(function (PHPMailer $mail, PhoreMailer $phoreMailer) {
$res["to"] = $mail->getAllRecipientAddresses();
$res["subject"] = $mail->Subject;
$res["html"] = $mail->Body;
$res["text"] = $mail->AltBody;
});
```