Reputation: 647
I am implementing the email functionality and its also working fine . Now i have to debug in local so had done some changes as shown below in app/config/email.php i have created this
public $test = array(
'from' => 'you@localhost',
'transport' => 'Debug',
);
Now in my controller i have write the below code
$Email = new CakeEmail('test');
$email->template('adddoctor', 'add');
//$email->emailFormat('html');
$email->from('[email protected]');
$email->to('[email protected]');//$data['User']['email_id'];
$email->subject('Account Detail');
$email->send();
after sending mail it redirects to the index page . so in index.ctp file i have write
<?php echo $this->Session->flash('email'); ?>
i dont want to send actual mail but i just only want to show it. so can any one tell me which changes still i have to do for email debug ? here some has given the answer CakeEmail debug
but dont understand where to write that code ?
Upvotes: 0
Views: 4068
Reputation: 21
$response = $Email->send();
$response['headers']; // headers as string
$response['message']; // message body with attachments
$this->Session->setFlash($response['headers'].$response['message']);
Make sure you have the following in your layout file.
echo $this->Session->flash();
Upvotes: 1
Reputation: 2438
$Email = new CakeEmail('test');
$email->template('adddoctor', 'add');
You're creating object as $Email
and using as $email
is it typo?
Upvotes: 1
Reputation: 14544
This is what you need to do to have your emails saved to the log, which is related to the solution for the other question you are trying to implement:
app/Config/email.php
public $test = array(
'log' => true
);
Your Controller
$Email = new CakeEmail('test');
$email->template('adddoctor', 'add');
$email->from('[email protected]');
$email->to('[email protected]');
$email->subject('Account Detail');
$email->send();
If you then go into app/tmp/logs/debug.log you will see an entry for your email, which includes the headers and message
2012-11-27 14:37:47 Debug:
From: My Site <[email protected]>
X-Mailer: CakePHP Email
Date: Tue, 27 Nov 2012 14:37:47 +0000
Message-ID: <[email protected]>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
My message
However, in my opinion this is all fairly useless unless you want to see the headers. For a start, you can't actually 'see' what your email will look like, and secondly, the email will continue to send to the recipient.
If you want to see what the actual layout/CSS of your email looks like you are probably better off just sending yourself some test emails.
I don't know why Cake got rid of the old email debugging functionality, as it was more helpful.
Upvotes: 4