第一步,在前端留言中加一个下拉菜单来选择对应的邮箱部门
<form class="my-4" action="{hmcms:msgaction}" method="post" > <!-- 邮箱选择下拉框 --> <select name="to_email" required> <option value="" disabled selected>请选择要留言的部门</option> <option value="284292114@qq.com">部门A</option> <option value="121915698@qq.com">部门B</option> <option value="284292114@leitu.vip">部门C</option> <option value="admin@ling-teng.cn">部门D</option> <option value="e@example.com">部门E</option> <option value="f@example.com">部门F</option> <option value="g@example.com">部门G</option> <option value="h@example.com">部门H</option> </select>
第二步:在:apps/home/controller/MessageController.php文件中修改以下代码
if ($this->config('message_send_mail') && $this->config('message_send_to')) { $mail_subject = lang('form.mail.subject', $value->form_name); $mail_body .= '<br>' . lang('form.mail.lastbody') . ' ' . get_http_url() . ' (' . date('Y-m-d H:i:s') . ')'; sendmail($this->config(), $this->config('message_send_to'), $mail_subject, $mail_body, lang('form.mail.nickname')); }
修改成:
if ($this->config('message_send_mail')) { $mail_subject = lang('form.mail.subject', $value->form_name); $mail_body .= '<br>' . lang('form.mail.lastbody') . ' ' . get_http_url() . ' (' . date('Y-m-d H:i:s') . ')'; // 默认邮箱 $mailto = $this->config('message_send_to'); // 如果表单传了 to_email,就直接使用它 if (!empty($_POST['to_email'])) { $mailto = $_POST['to_email']; } sendmail($this->config(), $mailto, $mail_subject, $mail_body, lang('form.mail.nickname')); }
下一篇:没有了!