Why php function dosen't work but same script in form plug-in is working.

heero

New Member
Hi Rob

I have e php code in form plugin generating pdf file from HTML. Its working great. But if i use exactly the same code as php function its not working.

What do I miss?

here is my script that calls function.
PHP:
require_once JPATH_ROOT . '/plugins/fabrik_form/php/scripts/timotech.php';

my_code();
 
Without seeing the code in timotech.php, I can't really help.

Do you have error reporting set to Max in J!'s global server config? If so, is it pitching any errors or warnings?

-- hugh
 
Here is the function in timotech.php

PHP:
<?php
function my_code();{
 
//t??tab
//failid emailile
 
$remail = "{email}";
$rname="{firstname} {lastname}";
$semail="info@info.eu";
$sname="Name.eu";
$cc="";
$bcc="";
$subject="Car {regnum} valuation documents. Order number {id}.";
$message="Than you for your buisness. PHP";
$priority="";
$type="";
 
//format location:type:name
 
$attachments = array("timotech/den/temp/aaa/{regnum}_invoice.pdf:doc/pdf:{regnum}_invoice.pdf",
                    "timotech/den/temp/aaa/02.pdf:doc/pdf:02.pdf",
                    "timotech/den/temp/aaa/03.pdf:doc/pdf:03.pdf");
 
 
 
// Checks if carbon copy & blind carbon copy exist
if($cc != null){$cc="CC: ".$cc."\r\n";}else{$cc="";}
if($bcc != null){$bcc="BCC: ".$bcc."\r\n";}else{$bcc="";}
 
// Checks the importance of the email
if($priority == "high"){$priority = "X-Priority: 1\r\nX-MSMail-Priority: High\r\nImportance: High\r\n";}
elseif($priority == "low"){$priority = "X-Priority: 3\r\nX-MSMail-Priority: Low\r\nImportance: Low\r\n";}
else{$priority = "";}
 
// Checks if it is plain text or HTML
if($type == "plain"){$type="text/plain";}else{$type="text/html";}
 
// The boundary is set up to separate the segments of the MIME email
$boundary = md5(@date("Y-m-d-g:ia"));
 
// The header includes most of the message details, such as from, cc, bcc, priority etc.
$header = "From: ".$sname." <".$semail.">\r\nMIME-Version: 1.0\r\nX-Mailer: PHP\r\nReply-To: ".$sname." <".$semail.">\r\nReturn-Path: ".$sname." <".$semail.">\r\n".$cc.$bcc.$priority."Content-Type: multipart/mixed; boundary = ".$boundary."\r\n\r\n";
 
// The full message takes the message and turns it into base 64, this basically makes it readable at the recipients end
$fullmessage .= "--".$boundary."\r\nContent-Type: ".$type."; charset=UTF-8\r\nContent-Transfer-Encoding: base64\r\n\r\n".chunk_split(base64_encode($message));
 
// A loop is set up for the attachments to be included.
if($attachments != null) {
  foreach ($attachments as $attachment)  {
    $attachment = explode(":", $attachment);
    $fullmessage .= "--".$boundary."\r\nContent-Type: ".$attachment[1]."; name=\"".$attachment[2]."\"\r\nContent-Transfer-Encoding: base64\r\nContent-Disposition: attachment\r\n\r\n".chunk_split(base64_encode(file_get_contents($attachment[0])));
  }
}
 
// And finally the end boundary to set the end of the message
$fullmessage .= "--".$boundary."--";
 
return mail($rname."<".$remail.">", $subject, $fullmessage, $header);
 
 
 
}
?>
 
We are in need of some funding.
More details.

Thank you.

Members online

Back
Top