danielmcormond / postmark-cakephp

A CakePHP 1.3 component used for sending email via the Postmark delivery service
http://danielmcormond.com/2010/07/16/postmark-cakephp-component/
17 stars 1 forks source link

Not working, and not getting any debug readout #2

Closed wcolbert closed 14 years ago

wcolbert commented 14 years ago
                    Configure::write('Postmark.uri', 'http://api.postmarkapp.com/email');
        Configure::write('Postmark.key', 'xxxxxxxxxxxxxxxxxxxxxxxxxxx');
        $this->Postmark->delivery = 'postmark';
        $this->Postmark->from = '<xxxxxxxxxxxxxxxxxxxxxxxxxx>';
        $this->Postmark->to = xxxxxxxxxxxx;
        $this->Postmark->subject = 'xxxxxxxxxxxxxx';
        $messageBody = 'xxxxxxxxxxxxxxxxxxxx';
        $result = $this->Postmark->send($messageBody);
        Debugger::log($result, $level = 7);

Am I doing something wrong?

danielmcormond commented 14 years ago

Are you writing those configuration values in your controller?

You need to put them in app/config/core.php so they are available when the component is instantiated.

wcolbert commented 14 years ago

I have this code in my core.php

Configure::write('Postmark.uri', 'http://api.postmarkapp.com/email'); Configure::write('Postmark.key', 'xxxxxxxxxxxxxxxxxxxxxxxxxxx');

And I have this code in a function in my app controller. $this->Postmark->delivery = 'postmark'; $this->Postmark->from = '<xxxxxxxxxxxxxxxxxxxxxxxxxx>'; $this->Postmark->to = xxxxxxxxxxxx; $this->Postmark->subject = 'xxxxxxxxxxxxxx'; $messageBody = 'xxxxxxxxxxxxxxxxxxxx'; $result = $this->Postmark->send($messageBody); Debugger::log($result, $level = 7);

wcolbert commented 14 years ago

Also I added another debug line to print out the email I want the email to go to right before the send and it prints it out in the debug.log file just fine. I don't need to include the Email component since its imported in the component right?

If I just use thee email component it seems to work just fine btw.

wcolbert commented 14 years ago

This is what the code looks like when I send with the default cake email component. $this->Email->from = 'xxxxxxxxxxxxxxxxxxxxxxxxxx'; $notify_user = xxxxxxxxxxxxxxxxxxxxxxxxxx; $this->Email->to = xxxxxxxxxxxxxxxxxxxxxxxxxx; $this->Email->subject = xxxxxxxxxxxxxxxxxxxxxxxxxx; $this->Email->sendAs = 'html'; $this->Email->send($messageBody); I can verify that this works perfectly.

danielmcormond commented 14 years ago

Correct, you do not need to include the Email component. It is imported within the Postmark component.

I'd recommend trying a simple test like this:

<?php
class TestsController extends AppController {
    var $uses = array();
    var $components = array('Postmark');

    public function index() {
        $this->Postmark->delivery = 'postmark';
        $this->Postmark->from = 'Test Sender <sender@domain.com>';
        $this->Postmark->to = 'Test Recipient <recipient@domain.com>';
        $this->Postmark->subject = 'Test Subject';
        $messageBody = 'This is a test message.';
        $result = $this->Postmark->send($messageBody);
        $this->log($result, 'debug');
    }
}
?>

If Postmark doesn't like your input, you'll see it's response in the return value from send(). If you're not seeing anything, chances are your code isn't finding or using the component correctly.

Let me know.