EllisLab text mark
Advanced Search
     
Dmail (An upgraded/rewrote email library) - CI2/PHP5
Posted: 16 November 2010 02:42 AM   [ Ignore ]
Avatar
Joined: 2008-09-07
93 posts

As not to scare away people with the amount of writing I like to do, this is simply a replacement to the email class + a few extras. Its currently a work in process, although everything I have thrown at it has completed correctly.

Current Features:
- Sending using Mail, Sendmail, and SMTP [New]
- Multiple recipients (Direct, Carbon Copy, Blind Carbon Copy)
- HTML or Plaintext email
- Attachments (From file or dynamic)
- Word wrapping
- Priorities
- BCC Batch Mode [New]
- Debugging Tools (A little more comprehensive than the default Email class)
- Automatic multipart creation (Detects how many parts, then makes a multipart if needed)
- Method chaining
- Set plain text with $this->dmail->text(’...’) and html with $this->dmail->html(’...’)
- Easy adding/editing of headers to be sent (Ex: $this->dmail->setHeader(‘Content-Type’, ‘text/html’);)
- Load mimes from application/config/mimes.php
- Uses the new driver design

Any info related to bugs, your mileage, and anything else is welcome smile

Installing:
- Extract the .zip file
- Place folder in application/libraries
- Load dmail and use it!

Documentation:
All of the functionality of the original has been ported over. Please refer to the Email Class documentation for usage. The new additions are:

/**
 * Dynamically attaches a file to the email.
 * @param String $contents The contents of the attachment
 * @param String $filename The filename to use in the email
 * @param String $disposition Defaults to attachment, can also be inline?
 * @return Dmail
 */
public function dynamic_attach($contents$filename$disposition 'attachment'
/**
 * Sets the HTML content to place into the email.
 * @param String $html The emails HTML
 * @return Dmail 
 */
public function html($html
/**
 * Sets the Plain Text content to place into the email.
 * @param String $html The emails Plain Text
 * @return Dmail 
 */
public function text($text

GitHub Page

Any questions just ask!

Well, that’s about it… Hope someone other than me would find this useful smile

 Signature 

Gfxtub.com - Image Hosting site built on CodeIgniter (Work in progress but fully operational).
Dmail v0.2 - A rewrote/updated email class for CI2 w/ PHP5
- Kris

 
Posted: 16 November 2010 04:45 AM   [ Ignore ]   [ # 1 ]   [ Rating: 0 ]
Avatar
Joined: 2010-09-17
606 posts

505 error - http://files.dudeami.com/dmail.php

 Signature 

I love lasagne!

 
Posted: 16 November 2010 11:56 AM   [ Ignore ]   [ # 2 ]   [ Rating: 0 ]
Avatar
Joined: 2008-09-07
93 posts

Opps, was meant to be .txt at the end, teaches me to post late at night (Updated the link in the post also).

 Signature 

Gfxtub.com - Image Hosting site built on CodeIgniter (Work in progress but fully operational).
Dmail v0.2 - A rewrote/updated email class for CI2 w/ PHP5
- Kris

 
Posted: 18 November 2010 05:36 AM   [ Ignore ]   [ # 3 ]   [ Rating: 0 ]
Avatar
Joined: 2008-09-07
93 posts

Updated to v0.2. Almost everything should be compatible with the default CI Email class.

 Signature 

Gfxtub.com - Image Hosting site built on CodeIgniter (Work in progress but fully operational).
Dmail v0.2 - A rewrote/updated email class for CI2 w/ PHP5
- Kris

 
Posted: 10 December 2010 08:58 PM   [ Ignore ]   [ # 4 ]   [ Rating: 0 ]
Joined: 2009-01-21
48 posts

Nice work, im trying to use here,

$this->dmail->bcc($array_list)
        ->
from($from)
        ->
subject($subject)
        ->
message($this->input->post("body"TRUE))
        ->
mailtype('html')
        ->
send(); 

And getting a message:

Fatal error: func_get_args(): Can’t be used as a function parameter in C:\UwAmp\_ci_\system\libraries\DMail\Dmail.php on line 189

Thx man

 
Posted: 10 December 2010 09:09 PM   [ Ignore ]   [ # 5 ]   [ Rating: 0 ]
Avatar
Joined: 2008-09-07
93 posts

I updated the class at github, should fix the problems your having smile If not let me know.

 Signature 

Gfxtub.com - Image Hosting site built on CodeIgniter (Work in progress but fully operational).
Dmail v0.2 - A rewrote/updated email class for CI2 w/ PHP5
- Kris

 
Posted: 10 December 2010 09:34 PM   [ Ignore ]   [ # 6 ]   [ Rating: 0 ]
Joined: 2009-01-21
48 posts

‘re cool now. My memory is bad or had a post with his previous few examples of its use? =p

 
Posted: 14 December 2010 05:33 PM   [ Ignore ]   [ # 7 ]   [ Rating: 0 ]
Avatar
Joined: 2006-08-06
918 posts

i’d like to be wrong about this, so please correct me… if i am, wrong, that is. grin

this looks like a bunch of CI Email class functions were just pasted into the extended class for no reason (or at least not a clear reason) leading to lots of redundant code.

there do seem to be a few new features and it’s nice to see someone trying the Drivers capability in CI2, but overall I think this could be trimmed way down.

good luck.

 Signature 

peeker email (imap/pop) | site_migrate | OOCalendar | PhotoBox2 | word_limiter

 
Posted: 14 December 2010 06:05 PM   [ Ignore ]   [ # 8 ]   [ Rating: 0 ]
Avatar
Joined: 2008-09-07
93 posts

Quick Answer: This library is rewritten from scratch, minus a few code snippets (documented) that already did the job fine.

Long Answer:
Well, the way I made it was to duplicate the functionality of the original class, so a lot of the end-user code is the same. A large percentage (I’d say 80-90%, but I could be wrong :p) of the code is from scratch. Some functions I took from the CodeIgniter email class, with small to large changes in the code (All these functions have credits to CodeIgniter in the PHPDoc). If you’d like to see the differences in the classes, just compare the way they handle certain things (Creating headers, creating messages, etc).

On the topic of trimming down/optimizing/improving code, feel free to create a fork on github or point out somethings that could be better smile

Hope this clears up any confusion :p

Edit: It just occurred to me you might mean the functions do the same thing, and yes they do :p The reason I rewrote it was the email class caused errors for me in certain parts, and the original was hard to extend and wasn’t well documented. The way certain things were done (Like attaching a text message to the header variable) seemed odd, so I rewrote the library in a way that made “more sense” in my opinion. The code is redundant, but I feel its easier to understand (Of course thats kind of bias… I wrote it) and easier to extend if needed. I don’t know about performance though :p

 Signature 

Gfxtub.com - Image Hosting site built on CodeIgniter (Work in progress but fully operational).
Dmail v0.2 - A rewrote/updated email class for CI2 w/ PHP5
- Kris