Solution: White/Blank Screen after Submit New Ticket OR New Message
i tried using Zoidbergs instructions, but whenever someone make a new ticket or a reply to a ticket, they can only see white screen.. does anyone have ideas on what to do? please..
I made Zoidberg's mods to my installation of osticket 1.6rc4 and experienced this problem as well. It was due to the fact that the PHPMailer class was being declared twice because in (his) mods the inclusion of mail.php is inside osticket's sendmail() function in includes/class.misc.php- which (assuming you have notifications to Admin and/or staff turned on in osticket) is called multiple times on submission of a new ticket or message (i.e. once to send the autoresponder to the submitting client, and then additionally, one or more times to the configured notification receivers).
To fix this:
In mail.php, comment out the include for PHPMailer: ~line ? (depends on your script):
//include("class.phpmailer.php");
You might also destroy the $mail object after the script terminates successfully. At the bottom of the script after:
if(!$mail->Send())
{
//echo $to."";
//echo "email_has_not_been_sent ";
echo "" . $mail->From . "";
echo "Mailer Error: " . $mail->ErrorInfo;
$IsSent = 0;
//exit();
}
Add:
unset($mail);
Next, in include/class.misc.php:
At the top, just BEFORE:
class Misc { declaration (~line 18),
Add:
include("mail/class.phpmailer.php");
That should fix the issue. As a fallback I also modified the sendmail() function in include/class.misc.php so that it will first attempt to send via SMTP with PHPMailer, and if that fails, revert back to using the standard PHP mail() function:
~ line 57 (1.6rc4):
/* Send email out after minor cleanups..*/
function sendmail($to, $subject, $message, $fromaddress,$fromname='', $xheaders = '') {
//TODO: Log all outgoing emails??
$eol="\n";
$addparam = "-fyourknownaddress@yourdomain.ext";
$fromname=$fromname?$fromname:$fromaddress;
//do some cleanup...avoid stupid errors.
$to=preg_replace("/(\r\n|\r|\n)/s",'', trim($to));
$subject=preg_replace("/(\r\n|\r|\n)/s",'', trim($subject));
$message = preg_replace("/(\r\n|\r)/s", "\n", trim($message));
/* First attempt send via SMTP with PHPMailer */
include(INCLUDE_DIR.'mail/mail.php');
if(!$IsSent == 1) {//failed...now attempt using PHP mail();
#Headers
$headers .= "From: ".$fromaddress.$eol;
$headers .= "Reply-To: ".$fromaddress.$eol;
$headers .= "Return-Path: ".$fromaddress.$eol;
$headers .= "Message-ID: ".time()."-".$fromaddress.$eol;
$headers .= "X-Mailer: MyMailer v x.xx".$eol;
if($xheaders) { //possibly attachments...does mess with content type
$headers .= $xheaders;
}else{
$headers .= "Content-Type: text/plain; charset=utf-8".$eol;
$headers .= "Content-Transfer-Encoding: 8bit".$eol;
}
@[deleted]($to,$subject,$message,trim($headers),$addparam);
}
}
Note: The $addparam (optional) forces the envelope_from for the message to be set to the specified address with the -f sendmail flag. Nobody likes email from 'nobody'! The address specified after -f MUST be valid.
**For some reason in the preview of this post the line:
@[deleted]($to,$subject,$message,trim($headers),$addparam); is displaying a space that shouldn't be there... ?? Make sure there is no space in the variable name $addparam in your code!
See: http://au2.php.net/function.mail(http://au2.php.net/function.mail) beneath 'additional_parameters (optional)'.
Osticket is great - I hope the above assists some other users!
BTW - This was done using PHPMailer v. 2.2.1. Osticket install on Linux/PHP 5.23/Apache 2.2.9 & cPanel