Loading... **表单提交时发送邮件** 1. 首先在phpcms后台找到邮箱配置 ![123.png][1] 2. 在后台设置->模块->表单向导添加接收邮件,即可实现前台表单提交邮箱收到邮件功能 ![456.png][2] 3. 一般情况下这个时候收到的邮件都是空白的,所以要去修改PHP代码 找到 `/phpcms/modules/formguide/index.php` 找到 `foreach ($mails as $m) { sendmail($m, L('tips'), $this->M['mailmessage']); }` 替换为 ```php $f_info = $this->db->get_one(array('modelid'=>$formid, 'siteid'=>$this->siteid)); $MailSubject = '用户提交表单['.$f_info['name'].']提醒'; $Fields = getcache('formguide_field_'.$formid, 'model'); $Fields['username']['name'] = '用户名'; $Fields['datetime']['name'] = '提交时间'; $Fields['ip']['name'] = '提交IP'; unset($data['userid'], $data['datetime']); foreach($data as $k=>$v){ $MailBody .= $Fields[$k]['name'].':'.$v.'<br />'; } foreach ($mails as $m) { sendmail($m, $MailSubject, $MailBody.$this->M['mailmessage']); } ``` [2]: https://www.huangshuxiu.com/usr/uploads/2022/09/3475713001.png [1]: https://www.huangshuxiu.com/usr/uploads/2022/09/4260822064.png 最后修改:2023 年 02 月 07 日 © 允许规范转载 打赏 赞赏作者 支付宝微信 赞 如果觉得我的文章对你有用,请随意赞赏