ส่วนของ Header
- Programming - PHP-1.png (31.44 KiB) Viewed 993 times
ลองเข้าไปแก้ไข header ของ phpbb มาตราฐาน
โค้ด: เลือกทั้งหมด
function build_header($to, $cc, $bcc) {
global $config, $phpbb_dispatcher;
// We could use keys here, but we won't do this for 3.0.x to retain backwards compatibility
$headers = array();
$headers[] = 'From: ' . $this->from;
if ($cc) {
$headers[] = 'Cc: ' . $cc;
}
if ($bcc) {
$headers[] = 'Bcc: ' . $bcc;
}
$headers[] = 'Reply-To: ' . $this->replyto;
$headers[] = 'Return-Path: <' . $config['board_email'] . '>';
$headers[] = 'Sender: <' . $config['board_email'] . '>';
$headers[] = 'MIME-Version: 1.0';
$headers[] = 'Message-ID: <' . $this->generate_message_id() . '>';
$headers[] = 'Date: ' . date('r', time());
$filename = 'receipt.pdf';
$file = '../images/receipt/' . $filename;
$headers[] = "Content-Type: application/octet-stream; name=\"" . $filename . "\"\r\n";
$headers[] = "Content-Transfer-Encoding: base64\r\n";
$headers[] = "Content-Disposition: attachment; filename=\"" . $filename . "\"\r\n\r\n";
// $headers[] = 'Content-Type: text/plain; charset=UTF-8'; // format=flowed
// $headers[] = 'Content-Transfer-Encoding: 8bit'; // 7bit
$headers[] = 'X-Priority: ' . $this->mail_priority;
$headers[] = 'X-MSMail-Priority: ' . (($this->mail_priority == MAIL_LOW_PRIORITY) ? 'Low' : (($this->mail_priority == MAIL_NORMAL_PRIORITY) ? 'Normal' : 'High'));
$headers[] = 'X-Mailer: phpBB3';
$headers[] = 'X-MimeOLE: phpBB3';
$headers[] = 'X-phpBB-Origin: phpbb://' . str_replace(array('http://', 'https://'), array('', ''), generate_board_url());
/**
* Event to modify email header entries
*
* @event core.modify_email_headers
* @var array headers Array containing email header entries
* @since 3.1.11-RC1
*/
$vars = array('headers');
extract($phpbb_dispatcher->trigger_event('core.modify_email_headers', compact($vars)));
if (count($this->extra_headers)) {
$headers = array_merge($headers, $this->extra_headers);
}
return $headers;
}
ให้เป็นแบบนี้
- Programming - PHP-2.png (35.63 KiB) Viewed 993 times
ส่วนของ Boby
โค้ด: เลือกทั้งหมด
$filename = 'receipt.pdf';
$file = '../images/receipt/' . $filename;
$file_size = filesize($file);
$handle = fopen($file, "r");
$file_content = fread($handle, $file_size);
fclose($handle);
$file_content = chunk_split(base64_encode(file_get_contents($file)));
$email_template = 'notification_member_package_email';
include_once($this->phpbb_root_path . 'includes/functions_messenger.' . $this->phpEx);
$messenger = new \messenger(FALSE);
$messenger->template($email_template, $data['user_lang']);
$messenger->to('[email protected]', $data['username']);
$messenger->anti_abuse_headers($this->config, $this->user);
$messenger->assign_vars(array(
'PACK_NAME' => $file_content, #htmlspecialchars_decode($content),
));
$messenger->send(NOTIFY_EMAIL);
ผลคือไฟล์จะส่งเเละเปิดได้
- Programming - PHP-3.png (29.91 KiB) Viewed 993 times
ต้องหาวิธีส่งค่า header ให้ใช้ได้ทั้งตัวอักษรเเละ PDF ส่งไปได้
ส่วนของ Header
[attachment=2]Programming - PHP-1.png[/attachment]
ลองเข้าไปแก้ไข header ของ phpbb มาตราฐาน
[code]function build_header($to, $cc, $bcc) {
global $config, $phpbb_dispatcher;
// We could use keys here, but we won't do this for 3.0.x to retain backwards compatibility
$headers = array();
$headers[] = 'From: ' . $this->from;
if ($cc) {
$headers[] = 'Cc: ' . $cc;
}
if ($bcc) {
$headers[] = 'Bcc: ' . $bcc;
}
$headers[] = 'Reply-To: ' . $this->replyto;
$headers[] = 'Return-Path: <' . $config['board_email'] . '>';
$headers[] = 'Sender: <' . $config['board_email'] . '>';
$headers[] = 'MIME-Version: 1.0';
$headers[] = 'Message-ID: <' . $this->generate_message_id() . '>';
$headers[] = 'Date: ' . date('r', time());
$filename = 'receipt.pdf';
$file = '../images/receipt/' . $filename;
$headers[] = "Content-Type: application/octet-stream; name=\"" . $filename . "\"\r\n";
$headers[] = "Content-Transfer-Encoding: base64\r\n";
$headers[] = "Content-Disposition: attachment; filename=\"" . $filename . "\"\r\n\r\n";
// $headers[] = 'Content-Type: text/plain; charset=UTF-8'; // format=flowed
// $headers[] = 'Content-Transfer-Encoding: 8bit'; // 7bit
$headers[] = 'X-Priority: ' . $this->mail_priority;
$headers[] = 'X-MSMail-Priority: ' . (($this->mail_priority == MAIL_LOW_PRIORITY) ? 'Low' : (($this->mail_priority == MAIL_NORMAL_PRIORITY) ? 'Normal' : 'High'));
$headers[] = 'X-Mailer: phpBB3';
$headers[] = 'X-MimeOLE: phpBB3';
$headers[] = 'X-phpBB-Origin: phpbb://' . str_replace(array('http://', 'https://'), array('', ''), generate_board_url());
/**
* Event to modify email header entries
*
* @event core.modify_email_headers
* @var array headers Array containing email header entries
* @since 3.1.11-RC1
*/
$vars = array('headers');
extract($phpbb_dispatcher->trigger_event('core.modify_email_headers', compact($vars)));
if (count($this->extra_headers)) {
$headers = array_merge($headers, $this->extra_headers);
}
return $headers;
}[/code]
ให้เป็นแบบนี้
[attachment=1]Programming - PHP-2.png[/attachment]
ส่วนของ Boby
[code] $filename = 'receipt.pdf';
$file = '../images/receipt/' . $filename;
$file_size = filesize($file);
$handle = fopen($file, "r");
$file_content = fread($handle, $file_size);
fclose($handle);
$file_content = chunk_split(base64_encode(file_get_contents($file)));
$email_template = 'notification_member_package_email';
include_once($this->phpbb_root_path . 'includes/functions_messenger.' . $this->phpEx);
$messenger = new \messenger(FALSE);
$messenger->template($email_template, $data['user_lang']);
$messenger->to('
[email protected]', $data['username']);
$messenger->anti_abuse_headers($this->config, $this->user);
$messenger->assign_vars(array(
'PACK_NAME' => $file_content, #htmlspecialchars_decode($content),
));
$messenger->send(NOTIFY_EMAIL);[/code]
ผลคือไฟล์จะส่งเเละเปิดได้
[attachment=0]Programming - PHP-3.png[/attachment]
ต้องหาวิธีส่งค่า header ให้ใช้ได้ทั้งตัวอักษรเเละ PDF ส่งไปได้