Ich brauche Hilfe in meinem PHP-Code. Meine Berichte werden in Eclipse BIRT erstellt und erhalten eine .rptdesign-Dateierweiterung, die ich über Google Mail senden möchte. Ich bin erfolgreich beim Senden, aber die Bilder sind kaputt und das CSS wird nicht angewendet. Hier ist mein CodeJavaBridge BIRT E-Mail senden
<html>
<body>
<hr>
<form action="PhpRunAndRenderHTMLEmbed.php" method="POST">
<input type="submit" name="submit" value="SEND">
</form>
<hr>
</body>
</html>
<?php
if (!(get_cfg_var('java.web_inf_dir'))) {
define ("JAVA_HOSTS", "127.0.0.1:8080");
define ("JAVA_SERVLET", "/JavaBridge/JavaBridge.phpjavabridge");
}
$pth = "http://" . $_SERVER["HTTP_HOST"] . $_SERVER["PHP_SELF"];
$path_parts = pathinfo($pth);
$imageURLPrefix = $path_parts['dirname'] ."/sessionChartImages/";
require_once("java/Java.inc");
session_start();
$here = getcwd();
$ctx = java_context()->getServletContext();
$birtReportEngine = java("org.eclipse.birt.php.birtengine.BirtEngine")->getBirtEngine($ctx);
java_context()->onShutdown(java("org.eclipse.birt.php.birtengine.BirtEngine")->getShutdownHook());
try{
$report = $birtReportEngine->openReportDesign("${here}/TopNPercent.rptdesign");
$task = $birtReportEngine->createRunAndRenderTask($report);
$taskOptions = new java("org.eclipse.birt.report.engine.api.HTMLRenderOption");
$outputStream = new java("java.io.ByteArrayOutputStream");
$taskOptions->setOutputStream($outputStream);
$taskOptions->setEmbeddable(true);
$taskOptions->setOutputFormat("html");
$ih = new java("org.eclipse.birt.report.engine.api.HTMLServerImageHandler");
$taskOptions->setImageHandler($ih);
$taskOptions->setEnableAgentStyleEngine(true);
$taskOptions->setBaseImageURL($imageURLPrefix . session_id());
$taskOptions->setImageDirectory($here . "/sessionChartImages/" . session_id());
$task->setRenderOption($taskOptions);
$task->run();
$task->close();
} catch (JavaException $e) {
echo $e; //"Error Calling BIRT";
}
echo $outputStream;
if(isset($_POST['submit'])){
require 'PHPMailer/PHPMailerAutoload.php';
$mail = new PHPMailer;
$mail->isSMTP(); // Set mailer to use SMTP
$mail->Host = 'smtp.gmail.com'; // Specify main and backup SMTP servers
$mail->SMTPAuth = true; // Enable SMTP authentication
$mail->Username = '[email protected]'; // SMTP username
$mail->Password = 'password'; // SMTP password
$mail->SMTPSecure = 'tls'; // Enable TLS encryption, `ssl` also accepted
$mail->Port = 587; // TCP port to connect to
$mail->setFrom('[email protected]', 'sample');
$mail->addReplyTo('[email protected]', 'sample');
$mail->addAddress('[email protected]'); // Add a recipient
$mail->isHTML(true); // Set email format to HTML
$bodyContent = '<p>This is the HTML email sent from localhost using PHP</p>';
$src = 'C:\xampp\htdocs\JavaBridge\sessionChartImages\6th1i2ih8j1r83o21iidi1qte0\custom6ab9ab811570c80985d2.png';
$mail->AddEmbeddedImage($src, 'chart_image', 'custom6ab9ab811570c80985d2.png');
$mail->Subject = 'BIRT PHP Email';
$bodyContent .= $outputStream;
$mail->Body = $bodyContent;
if(!$mail->send()) {
echo 'Message could not be sent.';
echo 'Mailer Error: ' . $mail->ErrorInfo;
} else {
echo 'Message has been sent';
}
}
?>
Was soll ich tun?
das Bild wird nicht angezeigt. Es zeigt nur das gebrochene Bildsymbol. Da JavaBridge eine Beispieldatei namens PhpRunAndRenderHTMLEmbed.php enthält, wird der gesamte Bericht als HTML gerendert und in einem Browser angezeigt. Aber wenn ich versuche, eine E-Mail mit dem gerenderten Bericht zu senden, wird das Bild nicht angezeigt –