Re: Publish a php extension smtpmail to PECL

From: Date: Wed, 14 Nov 2012 14:47:13 +0000
Subject: Re: Publish a php extension smtpmail to PECL
References: 1  Groups: php.pecl.dev 
Request: Send a blank email to pecl-dev+get-9973@lists.php.net to get a copy of this message
I like your approach, but I have three remarks: 1. I would separate building the email from sending the email into two different classes. 2. I would return the original object back, and use exceptions for error-conditions, that way you can use chaining. This would result in php code like this: $smtpmail->from($smtp_from, $smtp_from_name); ->to($smtp_to, $smtp_to_name); ->cc($smtp_cc, $smtp_cc_name); ->bcc($smtp_bcc, $smtp_bcc_name); ->attachment($smtp_attachment, $smtp_attachment_name); ->send($smtp_subject, $smtp_body); The DateTime class does something similar. Obviously in cases where these functions would return false because of an error situation, this should be replaced with throwing an exception and still return the object. 3. If I'm not mistaken, you used '#BOUNDARY#' as a separator between mime parts, this seems a little too simple. These remarks are personal opinions, feel free to ignore me. Greetings, Casper

« previous php.pecl.dev (#9973) next »