请求Ubuntu系统邮件客户端(Squirrel/Postfix)安装及问题解决指南
Postfix + SquirrelMail 完整部署指南及问题修复
一、环境准备
- 先把系统更新到最新:
apt update && apt upgrade -y - 安装必要依赖:
apt install apache2 php php-cli php-mysql php-curl php-gd php-intl php-mbstring php-xml php-zip -y
二、Postfix 安装与SMTP连接问题修复
1. 安装Postfix
apt install postfix -y
安装过程选「Internet Site」,输入你的服务器域名(比如example.com)
2. 基础验证
- 检查Postfix状态:
systemctl status postfix,必须显示active (running)才算正常 - 测试本地SMTP连接:
telnet localhost 25,看到220开头的欢迎信息就没问题,输入quit退出
3. 解决SMTP连不上的问题
- 开放防火墙端口:用ufw的话执行
ufw allow 25/tcp,其他防火墙工具对应开放25端口 - 修改Postfix监听设置:编辑
/etc/postfix/main.cf,确保inet_interfaces = all,保存后重启Postfix:systemctl restart postfix - 检查DNS配置:确认服务器的A记录和MX记录都指向当前主机IP,未配置的话先去域名服务商后台完成设置
三、SquirrelMail 安装与白屏修复
1. 安装SquirrelMail
apt install squirrelmail -y
2. 初始化配置
运行配置脚本:/usr/share/squirrelmail/config/conf.pl
按提示选择对应选项配置:
- 选
1. Organization Preferences,填写站点名称(比如我的邮件服务器) - 选
2. Server Settings,Domain填你的服务器域名,Sendmail or SMTP选smtp,SMTP Server填localhost - 选
4. General Options,确保Allow use of PHP设为Yes - 选
S保存配置,再选Q退出
3. 配置Apache访问
创建Apache配置文件:nano /etc/apache2/conf-available/squirrelmail.conf
粘贴以下内容:
Alias /webmail /usr/share/squirrelmail <Directory /usr/share/squirrelmail> Options Indexes FollowSymLinks AllowOverride None Require all granted </Directory>
启用配置并重启Apache:a2enconf squirrelmailsystemctl restart apache2
4. 解决白屏问题
- 查看PHP错误日志:
tail -f /var/log/apache2/error.log,如果是权限问题,执行chown -R www-data:www-data /usr/share/squirrelmail - 验证PHP扩展:
php -m,确保mysql、mbstring等扩展在列表中,缺失的话重新安装对应扩展 - 清除浏览器缓存:按Ctrl+F5强制刷新页面,或者用隐私窗口访问
http://你的服务器IP/webmail
四、最终测试
- 创建测试用户:
useradd testuser && passwd testuser,设置密码后访问http://服务器IP/webmail,用该账号登录 - 发送测试邮件到外部邮箱(比如xxx@gmail.com),确认能正常发送和接收
内容的提问来源于stack exchange,提问作者GobletofFireee
相关产品推荐
相关产品推荐

