Skip to content

Commit

Permalink
email testing stuff. sending a message to a test address for review.
Browse files Browse the repository at this point in the history
  • Loading branch information
dogmatic69 committed Dec 29, 2009
1 parent a50da05 commit 78b5e70
Show file tree
Hide file tree
Showing 10 changed files with 42 additions and 6 deletions.
38 changes: 32 additions & 6 deletions app/plugins/newsletter/controllers/newsletters_controller.php
Expand Up @@ -6,6 +6,10 @@ class NewslettersController extends NewsletterAppController
var $helpers = array(
);

var $components = array(
'Email'
);

function beforeFilter( )
{
parent::beforeFilter();
Expand Down Expand Up @@ -193,12 +197,39 @@ function admin_edit()

function admin_view( $id = null )
{
if ( !$id )
if ( !$id && empty( $this->data ))
{
$this->Session->setFlash( __( 'Please select a newsletter', true ) );
$this->redirect( $this->referer() );
}

if ( !empty( $this->data ) )
{
$addresses = explode( ',', $this->data['Newsletter']['email_addresses'] );
if ( empty( $addresses ) )
{
$this->Session->setFlash( __( 'Please input at least one email address for testing.', true ) );
$this->redirect( $this->referer() );
}

$newsletter = $this->Newsletter->read( null, $this->data['Newsletter']['id'] );

foreach( $addresses as $address )
{
$this->Email->from = 'Somebody <'.$newsletter['Newsletter']['from'].'>';
$this->Email->to = 'Test <'.$address.'>';
$this->Email->subject = strip_tags( $newsletter['Newsletter']['subject'] );
$this->set( 'email', $newsletter['Template']['header'].$newsletter['Newsletter']['html'].$newsletter['Template']['footer'] );
$this->Email->sendAs = 'both';
$this->Email->delivery = 'mail';

var_dump( $this->Email->send() );
exit;

$this->Email->reset();
}
}

$this->set( 'newsletter', $this->Newsletter->read( null, $id ) );
}

Expand Down Expand Up @@ -238,11 +269,6 @@ function admin_preview( $id = null )

}

function admin_testSend( $id = null )
{

}

function admin_delte()
{

Expand Down
1 change: 1 addition & 0 deletions app/plugins/newsletter/views/newsletters/admin_view.ctp
Expand Up @@ -8,6 +8,7 @@
<?php
echo $this->Form->create( 'Newsletter', array( 'action' => 'view' ) );
echo '<p>'.__( 'Enter the email addresses you would like to send to seperated by a , {comma}.', true ).'</p>';
echo $this->Form->input( 'id', array( 'value' => $this->params['pass'][0] ) );
echo $this->Form->input( 'email_addresses', array( 'type' => 'textarea', 'class' => 'title', 'value' => 'dogmatic69@gmail.com,carl@php-dev.co.za' ) );
echo $this->Form->end( 'Send the test' );
?>
1 change: 1 addition & 0 deletions app/views/elements/email/html/default.ctp
@@ -0,0 +1 @@
<?php echo $email; ?>
Empty file.
1 change: 1 addition & 0 deletions app/views/elements/email/text/default.ctp
@@ -0,0 +1 @@
<?php echo str_replace( '<br/>', "\r", strip_tags( $email ) ); ?>
Empty file.
6 changes: 6 additions & 0 deletions app/views/layouts/email/html/default.ctp
@@ -0,0 +1,6 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<body>
<?php echo $content_for_layout; ?>
</body>
</html>
Empty file removed app/views/layouts/email/html/empty
Empty file.
1 change: 1 addition & 0 deletions app/views/layouts/email/text/default.ctp
@@ -0,0 +1 @@
<?php echo $content_for_layout; ?>
Empty file removed app/views/layouts/email/text/empty
Empty file.

0 comments on commit 78b5e70

Please sign in to comment.