On Mon, Sep 15, 2008 at 7:33 PM, Bernhard Schussek <[EMAIL PROTECTED]> wrote:

> I would prefer the following API for sending mails:
>
> $mailer = new sfMailer(new Swift_Connection_SMTP('smtp.host.tld'));

Here, how can you manage the environment? Like this?

    $env = $this->getContext()->getConfiguration()->getEnvironment();

    if ('dev' === $env)
    {
      $mailer = new sfMailer(new Swift_Connection_Native());
    }
    else if ('prod' === $env)
    {
      $mailer = new sfMailer(new Swift_Connection_SMTP('smtp.host.tld'));
    }

It's gonna be hard to maintain... ;-)

> // or using YAML
> $mailer = new sfMailer(new sfConfiguredMailConnection('connnection_label'));
> // or even easier
> $mailer = new sfMailer('connection_label');
> // or, if the connection is named 'default'
> $mailer = new sfMailer();

Yes, but I think beeing able to configure this in the factories.yml
would be really interesting, and easy. Also, I find a bit strange to
define a mailer directly in a controller, I would personnaly prefer if
you just set the connection name you want to use only if you need to:

$message = new sfEmail();
$message->send(); // will use the default connection for current env
// or
$message->useMailer('connection_label'); // yeah, this one's defined
in the factories.yml file
$message->send();

> Here you still have the flexibility of using any of the Swift
> connections, and still you can use a very short syntax if the
> connection details are configured in a YAML file.

The YAML configuration array will be extracted from the factories.yml,
as the example I posted in my first message shows :-)

> Note that sfMailer should extend Swift to inherit all its capabilities.

That's what I'm currently planning to do, but this will end by
strongly coupling Swift and symfony. I don't see any danger right now,
though.

> Sending a mail would be easy as well:
>
> $message = new sfMail('My subject', 'My body');
> // or using a partial as body
> $message = new sfMail('My subject', 'module/partial_name');
> // or sending an HTML mail
> $message = new sfMail('My subject', 'module/partial_name', 'text/html');

Well, how can you use the same action to handle both html and plain
text templates with your last example? How do you use a component or
partial template as a mail template source? If all is magic, how are
you defining the template names to load? Maybe I'm missing something?
Maybe I'm wrong here, but I think users should be able to send emails
whith any template source, including symfony ones but others as well:

 - using a module/action and its associated templates (and have email
layout handling)
 - using a component
 - using a partial
 - defining a callback
 - using a simple string as a source
 - using file?
 - etc?

If everybody agree that every single developer will ever only have the
need to send emails using actions rendering as templates, well,
fine... But I'm not so sure. What do others think?

> $mailer->send($message, '[EMAIL PROTECTED]', '[EMAIL PROTECTED]');
> Once again, $message extends Swift_Message to inherit all
> capabilities. For everything that is non-symfony specific, users can
> read the good documentation of Swift. Its API is very easy to use
> anyway, so I think introducing a different API here makes no sense.

I agree. But the tricky part to me is to offer users a simple but
abstract way to define what will gonna be the source used for
templates, and right now Swift doesn't provide the feature... Or maybe
am I missing something?

One more time, this is the right time for making a decision (symfony
1.2 is planned for october), so let's discuss all together :)

++

-- 
Nicolas Perriault
http://prendreuncafe.com - http://symfonians.net - http://sensiolabs.com
Phone: +33 660 92 08 67

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"symfony developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/symfony-devs?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to