Zend email debug - debugging

I am trying to find an equivalent way to debug an email in Zend like I can in cakePHP. I want to see my test output before I send an email out for testing. I could just send the email to myself, and work bugs out that way, but I find that tedious.
//zend mail
$mail = new Zend_Mail();
$mail->setBodyHTML($content);
$mail->setBodyText($content);
$mail->setFrom('noreply#joe.com', 'Security Notification');
$mail->addTo('joeschmo#joe.com');
$mail->setSubject('(Security Notify) New Security Request');
//$mail->send();
//Equivalent to this from cakePHP
$this->Email->delivery = 'debug';
$this->Email->send('test message');
debug($this->Session->read('Message.email'));
die();

something like:
die($mail->getBodyHtml());
or
die(print_r($mail));

For your content in HTML, you can simply write:
echo $content; exit();
And for your content in plain text write:
echo '<pre>' . $content . '</pre>'; exit();

Related

How to send flash data in codeigniter when part of it is a link

I have to show flash data which contains a link. I tried the following but link is not shown as it should.
How can I add link in flashdata?
I tried this:
$cancell = "<a href='<?php echo site_url('document/index');?>Cancell</a>";
$this->session->set_flashdata('success',
'You successfully created the document! ' . $cancell .', if you want to cancell it!');
redirect('document/index/');
Try some thing like this code below, but make sure url helper autoloaded
URL Helper Codeigniter
Controller
$link = anchor('document/index', 'cancel');
$message = 'You successfully created the document!' .' '. $link .' '. 'if you want to cancell it!';
$this->session->set_flashdata('success', $message);
redirect('document/index');
View
<p><?php echo $this->session->flashdata('success');?></p>

codeigniter bcc doesn't work

Codeigniter "bcc" doesn't work, But the same code with "to" works just fine! Any suggestions why this happens and how to fix it?
Here's my code:
$email = "myEmail#myWebsite.com";
$subject = "my subject";
$message = "my message";
$this->email->set_mailtype("html"); // In my actual code this is needed
$this->email->from('myWebsiteEmail#myWebsite.com', 'Info');
// $this->email->to($email); // It works with this code
$this->email->bcc($email); // It doesn't work with this code
$this->email->subject($subject);
$this->email->message($message);
$this->email->send();
Any suggestions would be appreciated!
You have to have a to to be able to bcc
Try adding an email to the to as well as a bcc and it should work.
You may need to enable bcc_batch_mode in email config.
By default is value is FALSE.
It doesn't need a $this->email->to() all you need to do is set $config['bcc_batch_mode'] = TRUE; and then add the emails like $CI->email->bcc( $bccEmailArray );. The bcc method does not work like the cc method.

how to open pdf file to another tab in browser using codeigniter

im making currently making my thesis about a record management of our university secretary.. in which all papers inside the office will be scanned and uploaded in the system.. i am using codeigniter..one of the feature in my system is to view the pdf file in other window of the browser. but my problem is, when i click the title. only blank page will be displayed in the other tab.. can you help me solve this one?? here is my code
controller:
function viewMinutesFile(){
if(isset($_GET['id'])){
$id = $_GET['id'];
$file = $this->minutes_model->getFile($id);
$fp= fopen($file->path, "r");
header("Cache-Control: maxage=1");
header("Pragma: public");
header("Content-type: application/pdf");
header("Content-Disposition: inline; filename=".$file->filename."");
header("Content-Description: PHP Generated Data");
header("Content-Transfer-Encoding: binary");
header('Content-Length:' .filesize($file->path));
ob_clean();
flush();
while (!feof($fp)){
$buff = fread($fp,1024);
print $buff;
}
exit;
}
}
code to open the file: this is my syntax to be clicked by the user so that pdf file will be open in the new tab
File
index.php/admin/viewMinutesFile?
id=" target="_tab">
try this one with a static url. no need any extra words for that.
Show My Pdf
New Update
if its work for you then fetch pdf name from database and put the name in the view like
Show My Pdf
now in the controller
$this->load->helper('download');
if($this->uri->segment(3))
{
$data = file_get_contents('./file_path/'.$this->uri->segment(3));
}
$name = $this->uri->segment(3);
force_download($name, $data);
well, you could add a link to file with target="_blank", like
<a href="<?php echo base_url(). 'your_controller/viewMinutesFile'; ?>" target="_blank">
View Pdf
</a>
and in controller function:
function viewMinutesFile(){
....
$file = $this->minutes_model->getFile($id);
$this->output
->set_content_type('application/pdf')
->set_output(file_get_contents($your_pdf_file));
}
you can try this on your view :
Filename
and on your controller, you can try this, because this is works for me :
function viewfile(){
$fname = $this->uri->segment(3);
$tofile= realpath("uploaddir/".$fname);
header('Content-Type: application/pdf');
readfile($tofile);
}
hope this might help you...
Just create a link to a blank page and use this code in your controller:
public function myPdfPage(){
$url = base_url('assets/your.pdf');
$html = '<iframe src="'.$url.'" style="border:none; width: 100%; height: 100%"></iframe>';
echo $html;
}
Enjoy!
There is no any problem with your code you can open easily on next tab, like other pages only difference you have to change header description and it is make sure on your browser pdf reader add-ons are available, otherwise it will give you option to download.
You may just follow this.
<?php echo form_open_multipart('your_controller/your_function','target="_blank"') ;?>
//other input fields
<?php form_close();?>

How to check if there is a message in the message queue of joomla 2.5?

how can I check if there is a message in the message queue? for example how can I do something like :
<script type="text/javascript">
var message='<jdoc:include type="message" />'
if(message!="")
{
alert(message);
}
</script>
I am using joomla 2.5.
Thank you
So, the problem is really needing to strip the HTML from the message variable. Several things to note:
Joomla! could be returning multiple messages.
Alert are a blocking event for browsers... do you really want to do that?
First up you could place the messages in a JSON block by using some basic PHP.
<?php
$jAp = JFactory::getApplication();
$messagesJSON = json_encode($jAp->getMessageQueue());
?>
Then later in your template you could echo the messages JSON array into your Javascript similar to your original attempt.
<script type="text/javascript">
var messageJSON = <?php echo $messagesJSON; ?>
... then loop through the JSON block
This way you end up with just the text and type of the message and not the particular formatting of the current style/override.
i could not understand your question but you can get msg queue like this
$mainframe= JFactory::getApplication();
$messages = $mainframe->getMessageQueue();
if (is_array($messages)) {
echo '<ul id="system-messages">';
foreach($messages as $msg) {
echo '<li class="' . $msg['type'] . '">' . $msg['message'] . '</li>';
}
echo '</ul>';
}

Showing all session data at once?

I have tried the following but it is giving me errors:
print_r($this->session->userdata());
How can I show all session data in CodeIgniter?
print_r($this->session->userdata);
or
print_r($this->session->all_userdata());
Update:
As of version 3.1.11 the above methods are deprecated. Use the below method to get all session data,
print_r($this->session->userdata());
echo "<pre>";
print_r($this->session->all_userdata());
echo "</pre>";
Display yet formatting then you can view properly.
For print session data you do not need to use print_r() function every time .
If you use it then it will be non-readable format.Data will be looks very dirty.
But if you use my function all you have to do is to use p()-Funtion and pass data into it.
//create new file into application/cms_helper.php and load helper cms into //autoload or on controller
/*Copy Code for p function from here and paste into cms_helper.php in application/helpers folder */
//#parram $data-array,$d-if true then die by default it is false
//#author Your name
function p($data,$d = false){
echo "<pre>";
print_r($data);
echo "</pre>";
if($d == TRUE){
die();
}
}
Just remember to load cms_helper into your project or controller using $this->load->helper('cms'); use bellow code into your controller or model it will works just GREAT.
p($this->session->all_userdata()); // it will apply pre to your sesison data and other array as well
here is code:
<?php echo '<pre>' . print_r($_SESSION, TRUE) . '</pre>'; ?>

Resources