Quantcast

Fluent interfaces for Zend_Mail

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Fluent interfaces for Zend_Mail

Unknown User
Hello,
I think it would be nice if Zend_Mail supports fluent interfaces like
other parts of the framework.

Current usage: http://framework.zend.com/manual/en/zend.mail.html

|$mail = new Zend_Mail();
$mail->setBodyText('This is the text of the mail.')
     ->setFrom('[hidden email]', 'Some Sender')
     ->addTo('[hidden email]', 'Some Recipient')
     ->setSubject('TestSubject')
     ->send();|


Greetings
Waldemar

schott-waldemar.vcf (117 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: Fluent interfaces for Zend_Mail

Nico Edtinger
In general this shouldn't be a problem. But setBodyText() and  
setBodyHtml() both return the Zend_Mime_Part instance. If someone  
needs this he could of course also use getBodyText() and getBodyHtml().

Does someone use the return value of these two set methods? Otherwise  
I'll checkin Zend_Mail with fluent interfaces in my little incubator  
space.

nico


[18.11.2006 18:25] Waldemar Schott wrote:

> Hello,
> I think it would be nice if Zend_Mail supports fluent interfaces  
> like other parts of the framework.
>
> Current usage: http://framework.zend.com/manual/en/zend.mail.html
>
> |$mail = new Zend_Mail();
> $mail->setBodyText('This is the text of the mail.')
>     ->setFrom('[hidden email]', 'Some Sender')
>     ->addTo('[hidden email]', 'Some Recipient')
>     ->setSubject('TestSubject')
>     ->send();|
>
>
> Greetings
> Waldemar
> <schott-waldemar.vcf>


Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: Fluent interfaces for Zend_Mail

Matthew Ratzloff
As long as you don't do it for addAttachment() I think it's a good idea,
since there's no easy way to get at the attachment without a return value
(to set the filename, content type, etc.).

-Matt

----- Original Message -----
From: "Nico Edtinger" <[hidden email]>
To: "Waldemar Schott" <[hidden email]>
Cc: "ZF-General" <[hidden email]>
Sent: Saturday, November 18, 2006 10:09 AM
Subject: Re: [fw-general] Fluent interfaces for Zend_Mail


> In general this shouldn't be a problem. But setBodyText() and
> setBodyHtml() both return the Zend_Mime_Part instance. If someone  needs
> this he could of course also use getBodyText() and getBodyHtml().
>
> Does someone use the return value of these two set methods? Otherwise
> I'll checkin Zend_Mail with fluent interfaces in my little incubator
> space.
>
> nico
>
>
> [18.11.2006 18:25] Waldemar Schott wrote:
>> Hello,
>> I think it would be nice if Zend_Mail supports fluent interfaces  like
>> other parts of the framework.
>>
>> Current usage: http://framework.zend.com/manual/en/zend.mail.html
>>
>> |$mail = new Zend_Mail();
>> $mail->setBodyText('This is the text of the mail.')
>>     ->setFrom('[hidden email]', 'Some Sender')
>>     ->addTo('[hidden email]', 'Some Recipient')
>>     ->setSubject('TestSubject')
>>     ->send();|
>>
>>
>> Greetings
>> Waldemar
>> <schott-waldemar.vcf>
>
>

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: Fluent interfaces for Zend_Mail

Nico Edtinger
You could get the attachment via getParts() as Zend_Mail extends  
Zend_Mime_Message. But I also think that's not a really easy way to  
do it.

I think it would be nice if that could be added to the library  
directly instead of incubator, as it doesn't/shouldn't hurt. So I've  
created a task: http://framework.zend.com/issues/browse/ZF-564 with  
patch.

nico

[18.11.2006 19:55] Matthew Ratzloff wrote:

> As long as you don't do it for addAttachment() I think it's a good  
> idea, since there's no easy way to get at the attachment without a  
> return value (to set the filename, content type, etc.).
>
> -Matt
>
> ----- Original Message ----- From: "Nico Edtinger" <[hidden email]>
> To: "Waldemar Schott" <[hidden email]>
> Cc: "ZF-General" <[hidden email]>
> Sent: Saturday, November 18, 2006 10:09 AM
> Subject: Re: [fw-general] Fluent interfaces for Zend_Mail
>
>
>> In general this shouldn't be a problem. But setBodyText() and  
>> setBodyHtml() both return the Zend_Mime_Part instance. If someone  
>> needs this he could of course also use getBodyText() and  
>> getBodyHtml().
>>
>> Does someone use the return value of these two set methods?  
>> Otherwise I'll checkin Zend_Mail with fluent interfaces in my  
>> little incubator space.
>>
>> nico
>>
>>
>> [18.11.2006 18:25] Waldemar Schott wrote:
>>> Hello,
>>> I think it would be nice if Zend_Mail supports fluent interfaces  
>>> like other parts of the framework.
>>>
>>> Current usage: http://framework.zend.com/manual/en/zend.mail.html
>>>
>>> |$mail = new Zend_Mail();
>>> $mail->setBodyText('This is the text of the mail.')
>>>     ->setFrom('[hidden email]', 'Some Sender')
>>>     ->addTo('[hidden email]', 'Some Recipient')
>>>     ->setSubject('TestSubject')
>>>     ->send();|
>>>
>>>
>>> Greetings
>>> Waldemar
>>> <schott-waldemar.vcf>
>>
>


Loading...