Turns out this was due to my misunderstanding - obviously
swiftMailer_data has to be set() somewhere by the controller; in this
case it's automatically set if you use wrapBody from the swiftMailer
component.

However, having figured that out I'm still having a lot of problems
with this component. I expected it to be really good and perfect for
my needs, but unfortunately a combination of no docs seemingly
available for SwiftMailer v2 itself (i.e. the 3rd party script - only
v3 docs) and poor understanding on my part of how the component should
work are hampering me.

For example, I'm currently struggling to get the to/from addresses
added to the email. I had it earlier today, but using the "same code"
now and it's just adding the "name" of the sender/recipient but not
the email. I'm defining as:

$this->SwiftMailer->addTo('to','[EMAIL PROTECTED]','Damien');
$this->SwiftMailer->addTo('from',"[EMAIL PROTECTED]","recipient
name");

Then sending using:

if(!$this->SwiftMailer->sendView('my test email
subject','test','both')) { ...

In the resulting transaction log, I see this:

[command] => MAIL FROM:
and
[command] => RCPT TO:

(i.e. both are left blank like that). In the email headers, the same
applies, only the names are there (just no email addresses).

I'm using Swift 2.1.17, PHP5, Cake 1.1.14.

Does anyone have any ideas about any of this? I've given up trying to
use layouts, because just using views will work fine for my needs.
However, obviously not sending the email properly kinda works out a
dealbreaker!

Oh, and I'm trying to use the SMTP connection type (native PHP mail()
didn't work as PHP rejected it for some reason, and sendmail just
seemed to do nothing!). I have managed to get 1 single email out of
Swift using SMTP which is why I'm persisting with this...

Thanks in advance for any help or suggestions you can offer!

On Apr 26, 11:11 pm, Damien <[EMAIL PROTECTED]> wrote:
> Hi,
>
> I'm having some problems using theswiftmailercomponent described
> here:http://bakery.cakephp.org/articles/view/swiftmailer-component-tutorial
>
> When I try to send an email using the following code, I find a php
> notice in my logs:
>
> PHP Notice: Undefined variable: swiftMailer_data in /<snip>/app/views/
> email_contents/test_html.thtml on line 1
>
> Here's the code I'm using to send from my controller:
>
> if($this->SwiftMailer->connect()) {
>                     $this->SwiftMailer->addTo('to','[EMAIL 
> PROTECTED]','Damien');
>
>                     $this->SwiftMailer-
>
> >addTo('from',"[EMAIL PROTECTED]","from name here");
>
>                     if(!$this->SwiftMailer->sendView('my test
> email','test','both')) {
>                         echo "The mailer failed to Send. Errors:";
>                         pr($this->SwiftMailer->errors());
>                     }
>                 } else {
>                     echo "The mailer failed to connect. Errors:";
>                     pr($this->SwiftMailer->errors());
>                 }
>
> FYI, I have the following components in play:
> var $helpers = array('Javascript','DAuth','Html','Form');
> var $components = array('DAuth','RequestHandler','SwiftMailer');
>
> I'm not receiving the email - I guess because of the error with
> $swiftMailer_data in my (email) view?
>
> Has anyone got any ideas what's causing this and/or where I should
> look to fix?
>
> All help and suggestions much appreciated! Thanks.


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" 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/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to