Hi I am using codeigniter framework and CentOS. I am using a cron to send an html email , it calls to a php file from the cron , from the file i use ths command to call to a codegniter function
system("elinks -dump http://localhost/mailsender/index.php/mail/send/$email_job_id/");
from that i generate an html email .but the email html is not sending properly .
when i view the source of emil in my outlook , i can see ( this only a part of table )
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">Please check the Type Extension list.<br><br><table cellpadding="3D3D3D3D3=" D3="3D" D?="3D3D" 10="3D3D3D" ?="3D3D3D3D" st="3D3D3D3D3D" yle="3D3D3D3D3D3D"border:1px" solidblack;border-collapse:collapse;?="">
<tr>
<td style="3D3D3D3D3D3D"border:1px" solidblack;?="">Model</td>
<td style="3D3D3D3D3D3D"border:1px" solidblack;?="">Description</td>
<td style="3D3D3D3D3D3D"border:1px" solidblack;?="">Et</td>
<td style="3D3D3D3D3D3D"border:1px" solidblack;?="">Option Codes</td>
<td style="3D3D3D3D3D3D"border:1px" solidblack;?="">Order numbers</td>
</tr>
<tbody>
<tr><td style="3D3D3D3D3D3D"border:1px" solidblack;?="">2E32</td><td style="3D3D=" 3D3D="3D" 3D3D="3D3D" ?bor="3D3D3D" der:="3D3D3D3D" 1px="3D3D3D3D3D" solidblack;?="">216D GRAN TOURER RHD</td><td style="3D3D3D3D3D3D"border:1px" so="li=3D" d="3D3D" bl="3D3D3D" ac="3D3D3D3D" k;="3D3D3D3D3D" ?="">205,402,4UB,7LG</td><td style="3D3D3D3D3D3D"border:1px" solidblack;?="">2=
20=3D
97=3D3D
23=3D3D3D
76=3D3D3D3D
</=3D3D3D3D3D></tr>
My Mail sending function
function send($id) {
$this->load->library('email');
$config['protocol'] = 'smtp';
$config['useragent'] = 'GSPL';
$config['smtp_host'] = 'smtp.***';
$config['smtp_user'] = '';
$config['smtp_pass'] = '';
$config['wordwrap'] = TRUE;
$this->email->initialize($config);
$this->email->from("***");
$this->email->reply_to("***");
$this->email->subject("***");
$this->email->set_mailtype("html");
$new_email_body = $this->create_email_body();
$data->body = $new_email_body;
$this->email->message($data->body);
$this->email->to("*****");
$this->email->send();
}
create_email_body function will call to a view with the data
<table cellpadding="10" style="border:1px solid black;border-collapse: collapse;">
<tr>
<td style="border:1px solid black;">Model</td>
<td style="border:1px solid black;">Description</td>
<td style="border:1px solid black;">Et</td>
<td style="border:1px solid black;">Option Codes</td>
<td style="border:1px solid black;">Order numbers</td>
</tr>
<tbody>
<?php
foreach($result as $row)
{
echo '<tr><td style="border:1px solid black;">'.$row["model"].'</td><td style="border:1px solid black;">'.$row["description"].'</td><td style="border:1px solid black;">'.$row["et"].'</td><td style="border:1px solid black;">'.$row["option_codes"].'</td><td style="border:1px solid black;">'.$row["order_numbers"].'</td></tr>';
}
?>
</tbody>
<table>
Is there any way to send the correctly formatted HTML . Thank you in advance .
NOTE
The email is sending correctly formatted when i run the below directly in the browser .
http://localhost/mailsender/index.php/mail/send/***/
Table source i can see in outlook
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">Please check the Type Extension list.<br><br><table cellpadding="10" style="border:1px solid black;border-collapse: collapse;">
<tr>
<td style="border:1px solid black;">Model</td>
<td style="border:1px solid black;">Description</td>
<td style="border:1px solid black;">Et</td>
<td style="border:1px solid black;">Option codes</td>
<td style="border:1px solid black;">Order numbers</td>
</tr>
<tbody>
<tr><td style="border:1px solid black;">ABCD</td><td style="border:1px solid black;">test</td><td style="border:1px solid black;">ABC</td><td style="border:1px solid black;">222,222,22</td><td style="border:1px solid black;">22222,22222,2222</td></tr> </tbody>
<table>
Is there a reason why you use system and elinks?
You could running the cronjob via the CLI:
php path/to/index.php mail send "some_id"
Did you also tried it with wget or curl?
Related
I am using TCPDF stuff, I have created a PDF page with some Information. But i need to show some data to next page deliberately.
pdf -> AddPage();
above code is used to create a new page which i know. But i wanna add specific data to this particular page would be the problem.
Help me to come out on this issue.
I have written my code like this
while($row = mysql_fetch_array($query)){
$inv = $row["INVNUM"];
$weight = $row["WEIGHT"];
if($i<4){
if($row["SIZECODE"] == "02"){
$temp .= '<tr nobr="true">
<td class="size1" style="border:1px solid #000">'.$json_a[$i]["S"].'</td>
<td class="size2" style="border:1px solid #000">'.$json_a[$i]["M"].'</td>
<td class="size3" style="border:1px solid #000">'.$json_a[$i]["L"].'</td>
<td class="size4" style="border:1px solid #000">'.$json_a[$i]["XL"].'</td>
<td class="size5" style="border:1px solid #000">'.$json_a[$i]["2X"].'</td>
<td class="size6" style="border:1px solid #000">'.$json_a[$i]["3X"].'</td>
</tr>';
}
else if($row["SIZECODE"] == "03"){
$temp .= '<tr>
<td style="border:1px solid #000">'.$json_a[$i]["32"].'</td>
<td style="border:1px solid #000">'.$json_a[$i]["34"].'</td>
<td style="border:1px solid #000">'.$json_a[$i]["36"].'</td>
<td style="border:1px solid #000">'.$json_a[$i]["38"].'</td>
<td style="border:1px solid #000">'.$json_a[$i]["40"].'</td>
<td style="border:1px solid #000">'.$json_a[$i]["42"].'</td>
</tr>';
}
$i = $i+1;
}
else{
$pdf ->AddPage();
$i = 0;
$temp.='<tr nobr="true">
<td colspan="18" style="border:1px solid #000">All sales are Final.</td>
<td colspan="2" style="border:1px solid #000">SUB TOTAL:</td>
<td style="border:1px solid #000"></td>
<td style="border:1px solid #000"></td>
</tr>
<tr>
<td colspan="18" rowspan="2" style="border:1px solid #000">Number # : '.$rowFix["Num"].' </td>
</tr>
<tr>
<td colspan="2">TOTAL DUE: $</td>
<td style="border:1px solid #000"></td>
<td style="border:1px solid #000"></td>
</tr>';
}
}
I have to bring the table rows to the next page when the $i value greater than 4.
$pdf->AddPage('P', 'A4');
$pdf->Cell(0, 0, 'A4 PORTRAIT', 1, 1, 'C');
First, output the content for the first page. Then:
pdf -> AddPage();
Then, output for the second page. Anything sent after this command will be outputted onto the second page.
Why do the borders of my tables not appear when I print my pdf to the screen?
I'm using the mPDF library.
I create the tables in html and for some reason it is not showing.
I already tried using inline CSS but it didn't work, for me.
<?php
require_once 'MPDF57\MPDF57\mpdf.php';
class TablePDF {
public function printPDF() {
$mpdf = new mPDF();
$border = 2 ;
$mpdf->SetHeader("Tabela");
$mpdf->SetFooter("Tabela");
$htmlpdf= "
<html>
<head>
<link type='text/css' rel=' rel='heet' href=' href='tstrap.min.css'>
<link type='text/css' rel='stylesheet' href='css/estilo.css'>
<style type='.text/css.'>
<title>Table</title>
</style>
.td{
style='border: 1px solid';
}
</head>
<body>
<table class='tabela' border=".$border." style='border:10px solid;'>
<tr style='border:10px solid black'>
<th width='150' style='border:10px solid black; '>GE</th>
<td width='200' style='border:10px solid black; '>0</td>
<td width='200' style='border:10px solid black; '><strong>Nome Curto</strong></td>
<td width='200' style='border:10px solid black; '>0</td>
</tr>
</table>
<table class='tabela' border=".$border." style='border:10px solid black'>
<tr>
<th width='150'>Valor</th>
<td width='200'>0</td>
<td width='200'><strong>FG</strong></td>
<td width='200'>0</td>
</tr>
</table>
<table class='tabela' border=".$border." style='border:10px solid black'>
<tr>
<th width='150'> Jugular </th>
<td width='117'>0</td>
<td width='117'>0</td>
<td width='117'>0</td>
<td width='118'>0</td>
<td width='119'>0</td>
</tr>
</table>
<table class='tabela' border=".$border." style='border:10px solid black'>
<tr>
<th width='150'>EXP3D</th>
<td width='200'>0</td>
<td width='200'>0</td>
<td width='200'>0</td>
</tr>
</table>
<table class='tabela' border=".$border." style='border:10px solid black'>
<tr>
<th width='150'>EXP28D</th>
<td width='200'>0</td>
<td width='200'>0</td>
<td width='200'>0</td>
</tr>
</table>
<table class='tabela' border=".$border." style='border:10px solid black'>
<tr>
<th width='150'>Carotida</th>
<td width='303'>0</td>
<td width='303'>0</td>
</tr>
</table>
</body>
</html>";
$mpdf -> useOnlyCoreFonts = true;
$mpdf->WriteHTML($htmlpdf);
$mpdf->Output();
}
}
?>
Then I use this to use this function to print the pdf:
<?php
require_once 'TablePDF.php';
$var = new TablePDF();
$var->printPDF();
?>
EDIT: the problem has been solved, i just started deleting the table class in the TABLE tag line because for some reason it wastn recognizing it as a class.
thanks alot folks.
td {
border: 1px solid;
}
You don't have to create style every time that you need to use a td in your page, you only call the style.
First of all sorry for my bad english.
I have a php script that display a list of products from sql:
$cerereSQL = 'SELECT * FROM `produse`';
$rezultat = mysql_query($cerereSQL);
while($rand = mysql_fetch_array($rezultat)){
echo '
<form action="editare.php" method="post">
<table width="100%" cellpadding="0" cellspace="0">
<tr style="text-align:center;" height="25">
<td style="border:1px solid black;" width="7%" height="10"><i> '.$rand['indice'].' </i></td>
<td style="border:1px solid black;" width="40%"><i> '.$rand['denumire_produs'].' </i></td>
<td style="border:1px solid black;" width="20%"><i> '.$rand['producator'].' </i></td>
<td style="border:1px solid black;" width="10%"><i> '.$rand['pret'].' </i></td>
<td style="border:1px solid black;" width="6%"><i> '.$rand['valuta'].' </i></td>
<td style="border:1px solid black;" ><i> '.$rand['cod'].' </i></td>
<td width="5%"><input type="submit" name="submit" value="Edit"></td>
</tr>
</table>
</form>';
I want the button (value="Edit") from the end of each row to select exactly the product from the same row, to be edited.
I tried next code but did't work (i have a list with 5000 lines):
switch($_GET['actiune'])
{
case '':
$cerereSQL = 'SELECT * FROM `produse` WHERE denumire_produs="'.$rand['denumire_produs'].'"';
I know i have to use: $cerereSQL = 'SELECT * FROMproduseWHERE denumire_produs="......"; but i don't know how to do this, how to make the edit button, open the exactly product from the same row.
Can someone please help me with a suggestion?
Perhaps you mean to do this:
$cerereSQL = 'SELECT * FROM `produse`';
$rezultat = mysql_query($cerereSQL);
while($rand = mysql_fetch_array($rezultat)){
echo '
<form action="editare.php" method="post">
<table width="100%" cellpadding="0" cellspace="0">
<tr style="text-align:center;" height="25">
<td style="border:1px solid black;" width="7%" height="10"><i> '.$rand['indice'].' </i></td>
<td style="border:1px solid black;" width="40%"><i> '.$rand['denumire_produs'].' </i></td>
<td style="border:1px solid black;" width="20%"><i> '.$rand['producator'].' </i></td>
<td style="border:1px solid black;" width="10%"><i> '.$rand['pret'].' </i></td>
<td style="border:1px solid black;" width="6%"><i> '.$rand['valuta'].' </i></td>
<td style="border:1px solid black;" ><i> '.$rand['cod'].' </i></td>
<td width="5%"><input type="hidden" name="denumire_produs" value="'.$rand['denumire_produs'].'"><input type="submit" name="submit" value="Edit"></td>
</tr>
</table>
</form>';
Then, snag the denumire_produs from $_POST:
$denumire_produs = intval($_POST['denumire_produs']); // is this an INTeger? Otherwise, use `mysql_real_escape_string` -- or use PDO prepared statements.
$cerereSQL = 'SELECT * FROM `produse` WHERE denumire_produs="'.$denumire_produs.'"';
Is this what you're trying to do?
Four Things
First You dun need single Quotes around table name
$cerereSQL = 'SELECT * FROM produse';
Second Dont use mysql it is deprecated unless you really need to do
third you need to do this while you are echo any thing like that method=\"POST\" your code will not execute due to that
four you need hidden field
like that
<input type=\"hidden\" name=\"demuire\" value=\"'.$ran['whatever'].'\"/>
<td width="5%"><input type="submit" name="submit" value="Edit"></td>
then you can get this by simple
$_POST['demuire']
I'm using DOMPDF to generate pdf files from html. PDF file is getting generated but there are many blank pages are appearing in between content. Following is my php code.
<?php
$html=file_get_contents("views/testnew.html");
// echo $html;die();
$paper_orientation = 'landscape';
ob_start();
require_once("dompdf/dompdf_config.inc.php");
$pdfcontent = $html;
$dompdf = new DOMPDF();
$dompdf->set_paper('A4', $paper_orientation);
$dompdf->load_html($pdfcontent);
$dompdf->render();
// $pdf = $dompdf->output();
$pdf=$dompdf->stream("my_pdf.pdf", array("Attachment" => 0));
// file_put_contents('Brochure.pdf', $pdf);
?>
Following is my HTML that is I'm writing in PDF file
http://jsfiddle.net/6RmmB/
Since PDF is getting generated I don't think there is any problem with PHP code. Something must be wrong in html, But not able to figure it out what exactly ?
Or I'm missing something in PHP code ?
Content next to "Employer identification number" is appearing after about 8-9 blank pages
This looks to be due to a bug in how dompdf handles paging of table cells. If you remove the outer table, which appears to only exist to supply a border, the page will render better. You may still need to tweak the structure/styling, however, to get exactly what you want.
For example, instead of this:
<table width="100%" border="0" cellpadding="0" cellspacing="0" id="" style="border:1px solid #ccc;color: #000;font-family: Arial,Helvetica,sans-serif;font-size:14px;">
<tr>
<td>
<table width="100%" cellspacing="0" cellpadding="0" border="0" style="border-bottom:1px solid #ccc">
<tr>
<td width="15%" align="left" valign="top" style="border-right:1px solid #ccc;padding:10px;line-height:20px">Form
<img src="/var/www/html/pm5/bodytechniques/working/development/version5/therapist/images/w9-form.JPG" width="83" height="37" style="margin-left:15px" />
<br>(Rev. August 2013)
<br>Department of the Treasury
<br>Internal Revenue Service</td>
<td width="69%" align="left" valign="top" style="border-right:1px solid #ccc;padding:10px;text-align:center;line-height:45px">
<h1 align="center">Request for Taxpayer Identification Number and Certification</h1>
</td>
<td width="16%" align="left" valign="top">
<h3 style="line-height:25px;padding:10px">Give Form to the requester. Do not send to the IRS</h3>
</td>
</tr>
</table>
</td>
</tr>
</table>
Do this:
<div style="border:1px solid #ccc;color: #000;font-family: Arial,Helvetica,sans-serif;font-size:14px;">
<table width="100%" cellspacing="0" cellpadding="0" border="0" style="border-bottom:1px solid #ccc">
<tr>
<td width="15%" align="left" valign="top" style="border-right:1px solid #ccc;padding:10px;line-height:20px">Form
<img src="/var/www/html/pm5/bodytechniques/working/development/version5/therapist/images/w9-form.JPG" width="83" height="37" style="margin-left:15px" />
<br>(Rev. August 2013)
<br>Department of the Treasury
<br>Internal Revenue Service</td>
<td width="69%" align="left" valign="top" style="border-right:1px solid #ccc;padding:10px;text-align:center;line-height:45px">
<h1 align="center">Request for Taxpayer Identification Number and Certification</h1>
</td>
<td width="16%" align="left" valign="top">
<h3 style="line-height:25px;padding:10px">Give Form to the requester. Do not send to the IRS</h3>
</td>
</tr>
</table>
</div>
I have problem when multiple tables doesn't fit to one page.
Solution for this is easy, add <div style="clear: both;"> after table.
I have a table that returns information from mysql. However, I want to hyperlink each postcode so that when the user clicks on one it will redirect them to an appropriate page. Here is the code that is in the table:
<table style="border:2px solid black; border-collapse:collapse;" cellspacing="2" cellpadding="2" align="center">
<tr align="center" width="auto">
<td bgcolor="#66CCFF" style="border:2px solid black;"><b> Consultation Date </b></td>
<td bgcolor="#66CCFF" style="border:2px solid black;"><b> Patient Health Care Number </b></td>
<td bgcolor="#66CCFF" style="border:2px solid black;"><b> Location </b></td>
<td bgcolor="#66CCFF" style="border:2px solid black;"><b> Post Code </b></td>
<td bgcolor="#66CCFF" style="border:2px solid black;"><b> Update Record </b></td>
</tr>
<?php
$i=0;
while ($i < $num) {
$f1=mysql_result($result,$i,"Consultation Date");
$f2=mysql_result($result,$i,"Patient HCN");
$f3=mysql_result($result,$i,"Location");
$f4=mysql_result($result,$i,"Post Code");
?>
<tr>
<td align="center" bgcolor="#FFFFFF" style="border:2px solid black;"><?php echo $f1; ?></td>
<td align="center" bgcolor="#FFFFFF" style="border:2px solid black;"><b><?php echo $f2; ?></b></td>
<td align="center" bgcolor="#FFFFFF" style="border:2px solid black;"><?php echo $f3; ?></td>
<td align="center" bgcolor="#FFFFFF" style="border:2px solid black;"><?php echo "<a href=\"coveragehcp.php?patient= ". $f2 ."\">"?><b><?php echo $f4; ?></b></td>
<td align="center" bgcolor="#FFFFFF" style="border:2px solid black;"><?php echo "<button onclick=\"window.location.href='hcp_form_update.php?patient=$f2'\">"?>Update Record</button></td> <!-- This button redirects the user to the auto-populated form that holds the patients information which allows the user to update it -->
</tr>
<?php
$i++;
}
?>
However when the user click on the link below I want it to redirect them to another page according to the post code clicked.
<td align="center" bgcolor="#FFFFFF" style="border:2px solid black;"><?php echo "<a href=\"coveragehcp.php?patient= ". $f2 ."\">"?><b><?php echo $f4; ?></b></td>
What I would do is to use the post code as a parameter in the GET, and then use the $_GET['postcode'] to achieve which page should be presented for the user.
so your PHP code for the link would look something like:
<a href=\"coveragehcp.php?patient= ".$f2."&postcode=".$f4."\">"?><b><?php echo $f4; ?></b></td>
and on the coveragehcp.php page use this
$postcode = $_GET['postcode'];
if(!empty($postcode))
{
if($postcode == 90210) {
//Echo beverly hills page
}
else {
//Echo default page
}
}