php邮件多个收件人 [英] php mail multiple recepients

查看:129
本文介绍了php邮件多个收件人的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我可以通过在邮件程序中定义ID来发送电子邮件到一个电子邮件ID,但是当用户在表单中键入mssage和email id时,我无法理解如何发送到多个接收者。例如 - 我显示一个带有两个文本区域的表单 - 一个用于电子邮件ID,另一个用于自定义消息。所以当他们点击发送时,我想从该文本区域拿起电子邮件ID,并将该消息发送到这些ID。我还没有弄清楚如何使用逗号/空格分隔邮件,但是会在google搜索中尝试。

I am able to send email to one email id by defining the id in the mailer, but i am not able to understand how to send to multiple recepients when an user types "mssage and email id's" in a form. Ex - I am showing a form with two text areas - one for email id's and one for custom message. So when they click send, i want to take the email id's from that text area and send that message to those ids. I am yet to figure out how to comma/space seperate the emailds but will try it in google search.

谢谢

推荐答案

在进行一些搜索后,我带着这个答案发送多个地址,分号用分号分隔(由于某种原因我用这个代码中的逗号尝试失败,但是我的分号很好)

after doing some search, I came with this answer to send multiple address seperated by semicolon(for some reason my try with comma in this code failed, but i am fine with semicolon).

如果有人正在寻找JS验证来检查ID的输入

If in case if anyone is looking for JS validation to check the id's entered

var emailRegex = /^(([a-zA-Z0-9_\-\.]+)@([a-zA-Z0-9_\-\.]+)\.([a-zA-Z]{2,5}){1,25})+([;.](([a-zA-Z0-9_\-\.]+)@([a-zA-Z0-9_\-\.]+)\.([a-zA-Z]{2,5}){1,25})+)*$/;

当我收集的邮箱ID用分号分隔时,我不得不更换; with,

As i collected the email id's separated by semicolon, i had to replace ; with ,

$emails_tosend = preg_replace('/;/', ',', $emailid);

$ email id - 从表单收集

$email id - collected from the form

所以在做了上面的替换之后,我只是使用普通的to在邮件发送给多个收件人。

so after doing the above replacement, i just use the normal "to" in the mailer to send to multiple recipients.

$to = "$emails_tosend";
mail ($to, $subject, $message, $headers);

希望这有帮助,很明显。我可以解释一下是否需要更多的澄清。感谢您的帮助。

hope this helps and it's clear. I can explain if anyone needs more clarification. thanks for all your help.

这篇关于php邮件多个收件人的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆