设置 Webmail 在线预览 Office 文件

Winmail 6.3 版本以后,可以配置邮件服务器后台,实现在浏览器登录 Webmail 直接预览 Office 文件附件: doc、xls、ppt、docx、xlsx、pptx

目前已知以下客户端无需做这项设置就可以直接查看或者下载打开Office 文件:
  1. 安装了 Office 的 Windows 系统
  2. iOS 设备: iPhone、iPad
  3. 安装了 Office 的 安卓手机和移动设备
  4. Mac OS 系统
支持三种方式实现,调用两家第三方互联网文档预览在线服务,另外一种是在邮件服务器上安装类 Office 软件 LibreOffice[限服务器是 Windows平台],下面分别介绍设置方法,三种方法只能使用一种。
设置完成后在 Webmail 上阅读邮件时会在 Office 附件名旁边出现: ,如果设置后预览功能不生效,请重启一下 Winmail 里的 http 服务,重新登录 Webmail。

一、使用微软公司提供的免费 Office 文档预览在线服务

需要外网可以访问 Webmail,需要使用 http 80 或者 https 443 端口访问,6080等非标准端口不支持,客户端浏览器会定向访问 http://view.officeapps.live.com, 纯内网系统无法使用,速度一般,文件兼容性佳。设置方法:修改 ~/server/webmail/inc/config.php (去掉前面的注释符 // ) [6.6 以后版本是修改 ~/server/webmail/inc/config.user.php] 将
//$document_converter = 'https://view.officeapps.live.com/op/view.aspx?src=%s'; //...
改成
$document_converter = 'https://view.officeapps.live.com/op/view.aspx?src=%s'; //...
就是去掉前面的注释,如果 Webmail 会使用内部地址访问,要在 ~/server/webmail/inc/config.php [6.6 以后版本是修改 ~/server/webmail/inc/config.user.php] 里设置外部访问地址,例如外部地址是 http://demo.winmail.cn 将
$internet_location = '';
改成
$internet_location = 'http://demo.winmail.cn';
请注意 ~/server/webmail/inc/config.php 在升级或者重新安装 Winmail 会被覆盖,需要重新修改,建议修改保存后就备份一下。 [6.6 以后版本修改的 config.user.php 重新安装不会被覆盖]

二、使用永中提供的免费 Office 文档预览在线服务

http://www.yozodcs.com 申请"云转换"帐号, 登录"永中云转换用户控制台"增加 Webmail 访问域名,得到"域名key"


免费版本限制附件10M以内,调用500次/天, 需要外网可以访问 Webmail,支持 http 非标准端口,客户端浏览器会定向访问 http://p.dcsapi.com, 纯内网系统无法使用,速度好,文件兼容性好。假设[域名key]是 12345678,修改 ~/server/webmail/inc/config.php [6.6 以后版本是修改 ~/server/webmail/inc/config.user.php](修改 k 的赋值,并去掉前面的注释符 // ) 将
//$document_converter = 'http://dcsapi.com/?k=xxxx&url=%s'; //...
改成
$document_converter = 'http://dcsapi.com/?k=12345678&url=%s';
如果预览附件时页面提示"域名与K值不匹配,请确认后重新访问!",说明 Webmail 访问地址和"云转换"里加的不一致。 如果 Webmail 会使用内部地址访问和其他域名访问,要在 ~/server/webmail/inc/config.php [6.6 以后版本是修改 ~/server/webmail/inc/config.user.php]里设置外部访问地址,例如外部地址是 http://demo.winmail.cn:6080 将
$internet_location = '';
改成
$internet_location = 'http://demo.winmail.cn:6080';
请注意 ~/server/webmail/inc/config.php 在升级或者重新安装 Winmail 会被覆盖,需要重新修改,建议修改保存后就备份一下。 [6.6 以后版本修改的 config.user.php 重新安装不会被覆盖]

三、服务器安装 LibreOffice 使用本地工具转换功能[Windows平台]

无需外网,纯内网系统可以使用,支持 http 非标准端口,速度好,文件兼容性一般。 到 https://www.libreoffice.org 建议下载安装 LibreOffice 5.x.x 稳定版,

假设:安装目录是 C:\Program Files\LibreOffice 5, 假设自定义的访问 key 是 b8b1627656,Webmail 访问地址是 http://demo.winmail.cn

  1. 参考下面修改 ~/server/webmail/www/tohtml/convert.php
    $office_exec = 'C:\\Program Files\\LibreOffice 5\\program\\soffice.exe';
    $auth_key = array('b8b1627656');
    $auth_domain = array('demo.winmail.cn');
  2. 修改 ~/server/webmail/inc/config.php [6.6 以后版本是修改 ~/server/webmail/inc/config.user.php](修改 key 的赋值,并去掉前面的注释符 // )
    //$document_converter = 'http://xxxxxxxxxxxx/tohtml/convert.php?key=xxxx&url=%s'; // LibreOffice converter url
    改成
    $document_converter = 'http://demo.winmail.cn/tohtml/convert.php?key=b8b1627656&url=%s'; // LibreOffice converter url
请注意 ~/server/webmail/inc/config.php 在升级或者重新安装 Winmail 会被覆盖,需要重新修改,建议修改保存后就备份一下。 [6.6 以后版本修改的 config.user.php 重新安装不会被覆盖]