PHP Classes

PHP Delayed Email class: Queue email messages in files to send them later

Recommend this page to a friend!

  Author Author  
Picture of Eustaquio Rangel de Oliveira Jr.
Name: Eustaquio Rangel de ... is available for providing paid consulting. Contact Eustaquio Rangel de ... .
Classes: 6 packages by
Country: Brazil Brazil
Age: 52
All time rank: 27620 in Brazil Brazil
Week rank: 387 Down30 in Brazil Brazil Down
Innovation award
Innovation award
Nominee: 3x

Winner: 1x


  Detailed description   Download Download .zip .tar.gz   Install with Composer Install with Composer  
This package can Queue email messages in files to send them later.

The main class can compose messages and generates a MIME message body file that is stored in spool directory.

The messages are composed defining the sender, recipients, subject, message body text or HTML and attached files.

A sender class can monitor the spool directory regularly for queued message files. It sends the email messages via a given SMTP server.

Details
# Delayed Mail for PHP This is a simple app for sending emails through PHP without blocking sending and waiting answer from the SMTP server. It provides some classes as: - `Message` to compose the message - `Server` to connect to the SMTP server - `Sender` to run and send the queued messages - `Runner` to fire a Sender object ## How it works First we need the server configurations. There is a sample file on the `test` dir, called `delayedmail.ini`: ``` host = smtp.gmail.com port = 587 user = taq password = secret path = /tmp/delayedmailtest ``` The only different parameter there is the `path` parameter. This is where the mail files will be stored. **VERY IMPORTANT** If you use two-phase authentication on a Gmail account, **sending emails with this library will not work**. You need a less secure account to make it works. ## Storing messages to send later The data store used are just regular plain text files. They are stored on the `path` configured above. On that dir there will be another two subdirs: - `delivery` where the queued messages are. - `sent`, where the messages are moved *after* `Sender` send them. - `error`, where the messages are moved if there are some errors on them. ## How to use it ### Queuing messages Just include the `delayedmail.php` on your app, create a new `Server` object, configure it, compose and queue a new message: ```php <?php include_once "delayedmail.php"; $server = new DelayedMail\Server("myconfigs.ini"); $msg = new DelayedMail\Message(); $msg->from("taq <eustaquiorangel@gmail.com>")-> to("Eustaquio Rangel <taq@bluefish.com.br>")-> cc("Eustaquio Rangel <taq@anotherhost.com>")-> subject("DelayedMail test!")-> text("This is just\na test!")-> attach("taq.jpg"); $server->push($msg); ?> ``` If you check the `delivery` dir now, there will be a file there with the message contents. You can use arrays on `attach` and `cc`. ### Running the runner Just edit the `runner.php` file with the desired interval and configuration file (usually the same config file as the server) and run it from the command line: ```php <?php $dir = dirname(__FILE__); echo "- loading classes from $dir\n"; include_once "$dir/delayedmail.php"; $sender = new DelayedMail\Sender(5,"delayedmail.ini"); $sender->run(); ?> ``` ```php $ php runner.php - initializing ... - checking for files in /tmp/delayedmailtest/delivery ... - no files found. ``` ## Testing ### Sending emails Go to the `test` directory, configure the `delayedmail.ini` and `test.php` files to the configs you want, and run: ``` $ php test.php ``` And then check your email app on the addresses you configured. ### Code Run `composer update`, go to the `test` directory and run: ``` $ phpunit . ```

  Classes of Eustaquio Rangel de Oliveira Jr.  >  PHP Delayed Email class  >  Download Download .zip .tar.gz  >  Support forum Support forum (4)  >  Blog Blog  >  RSS 1.0 feed RSS 2.0 feed Latest changes  
Name: PHP Delayed Email class
Base name: delayed-email
Description: Queue email messages in files to send them later
Version: 1.0.13
PHP version: 5.3.0
License: GNU General Public License (GPL)
All time users: 532 users
All time rank: 5629
Week users: 0 users
Week rank: 116 Equal
 
  Groups   Rate classes User ratings   Applications   Files Files  

  Groups  
Group folder image Email Email sending and receiving View top rated classes
Group folder image PHP 5 Classes using PHP 5 specific features View top rated classes


  User ratings  
Not enough user ratings

  Applications that use this package  
No pages of applications that use this class were specified.

Add link image If you know an application of this package, send a message to the author to add a link here.

  Files folder image Files  
File Role Description
Files folder imagesrc (4 files)
Files folder imagetest (9 files)
Accessible without login Plain text file .codeclimate.yml Data Auxiliary data
Accessible without login Plain text file composer.json Data Auxiliary data
Accessible without login Plain text file delayedmail.php Aux. Auxiliary script
Accessible without login Plain text file README.markdown Data Auxiliary data
Accessible without login Plain text file runner.php Example Class source

  Files folder image Files  /  src  
File Role Description
  Plain text file Cleaner.php Class Class source
  Plain text file Message.php Class Class source
  Plain text file Sender.php Class Class source
  Plain text file Server.php Class Class source

  Files folder image Files  /  test  
File Role Description
  Accessible without login Plain text file attachment.txt Data Documentation
  Accessible without login Plain text file cleanerTest.php Test Unit test script
  Accessible without login Plain text file delayedmail.ini Data Auxiliary data
  Accessible without login Plain text file messageTest.php Test Unit test script
  Accessible without login Image file qat.jpg Icon Icon image
  Accessible without login Plain text file senderTest.php Test Unit test script
  Accessible without login Plain text file serverTest.php Test Unit test script
  Accessible without login Image file taq.jpg Icon Icon image
  Accessible without login Plain text file test.php Example Example script

Install with Composer Install with Composer - Download Download all files: delayed-email.tar.gz delayed-email.zip
NOTICE: if you are using a download manager program like 'GetRight', please Login before trying to download this archive.
  Files folder image Files  
File Role Description
Files folder imagesrc (4 files)
Files folder imagetest (9 files)
Accessible without login Plain text file .codeclimate.yml Data Auxiliary data
Accessible without login Plain text file composer.json Data Auxiliary data
Accessible without login Plain text file delayedmail.php Aux. Auxiliary script
Accessible without login Plain text file README.markdown Data Auxiliary data
Accessible without login Plain text file runner.php Example Class source

  Files folder image Files  /  src  
File Role Description
  Plain text file Cleaner.php Class Class source
  Plain text file Message.php Class Class source
  Plain text file Sender.php Class Class source
  Plain text file Server.php Class Class source

  Files folder image Files  /  test  
File Role Description
  Accessible without login Plain text file attachment.txt Data Documentation
  Accessible without login Plain text file cleanerTest.php Test Unit test script
  Accessible without login Plain text file delayedmail.ini Data Auxiliary data
  Accessible without login Plain text file messageTest.php Test Unit test script
  Accessible without login Image file qat.jpg Icon Icon image
  Accessible without login Plain text file senderTest.php Test Unit test script
  Accessible without login Plain text file serverTest.php Test Unit test script
  Accessible without login Image file taq.jpg Icon Icon image
  Accessible without login Plain text file test.php Example Example script

Install with Composer Install with Composer - Download Download all files: delayed-email.tar.gz delayed-email.zip
NOTICE: if you are using a download manager program like 'GetRight', please Login before trying to download this archive.