magento2实战笔记 -- 邮件设置

客户下完单后,需要工作人员在后台发送邮件通知客户目前的订单状态,此时就涉及到邮件发送模块。接下来就是模块的安装和使用流程。

安装sendmail模块

1
sudo apt install postfix (or sudo apt install sendmail)

解决问题

以下错误信息针对的是postfix。

安装问题

报错信息

newaliases: warning: valid_hostname: misplaced delimiter: tocartus..
newaliases: fatal: file /etc/postfix/main.cf: parameter myhostname: bad parameter value: tocartus..
dpkg: error processing package postfix (—configure):
installed postfix package post-installation script subprocess returned error exit status 75

原参数“tocartus..”不合法,不能连续出现’.’。

解决方案

编辑/etc/postfix/main.cf,修改myhostname。

使用问题

报错信息

发送邮件时出现warning:

postdrop: warning: unable to look up public/pickup: No such file or directory


缺失文件public/pickup。

解决方案

关闭sendmail服务

1
sudo service sendmail stop

创建文件pickup

1
mkfifo /var/spool/postfix/public/pickup

重启服务

1
sudo systemctl restart postfix.service

此外也可以设置服务开机启动

1
sudo systemctl enable postfix.service

安装MAGEPLAZA SMTP

安装方式详见mageplaza安装教程,装好后在magento2后台设置smtp相关参数,如Figure 1所示。需要特别指出的是,Host一栏填写的是你所使用邮箱发送服务器的地址,一般为smtp.xxxx.com。如果不清楚的话,可以登陆邮箱去设置里面查看。
Figure 1 配置SMTP
一切设置好后,点击“Send Test Email”进行测试,没有问题就可以保存了。

后续调整

邮件配置完后,我们还需要做一些细节上的调整。一个是邮件模块中的logo需要换成我们自己的logo。另外就是配置email address,如Figure 2所示。
Figure 2 邮件模板

进入CONTENT > Configuration,选择店铺编辑,在Transactional Emails中添加logo即可。

配置email address

进入STORES > Configuration > GENERAL > Store Email Addresses,将我们对应的邮箱地址添加进去即可。

Reference:
[1] https://stackoverflow.com/questions/38299776/usr-sbin-sendmail-not-found
[2] https://westonganger.com/posts/fix-for-postfix-error-postdrop-warning-unable-to-look-up-public-pickup-no-such-file-or-directory
[3] https://www.mageplaza.com/magento-2-smtp/?__cf_chl_captcha_tk__=pmd_cc7e473740129b46e9566ec121f993fbb6987dd5-1627015047-0-gqNtZGzNArijcnBszQkO


magento2实战笔记 -- 邮件设置
https://r-future.github.io/post/magento2-series-smtp/
Author
Future
Posted on
July 23, 2021
Licensed under