且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何使用php邮件一次发送多封电子邮件?

更新时间:2022-12-26 17:57:14

使用 mail()功能。


您在此主题上想要的所有信息只是 Google搜索


我感谢您的帮助,但要么您没有阅读我发布的内容,要么您忽略了它。


我知道如何使用mail()函数,我知道如何使用mail()函数发送到多个电子邮件地址。


但是你没有读过最重要的部分 - 它是大胆的! -

I appreciate your help but either you didn''t read what I posted or you ignored it..

I know how to use mail() function, I know how to send to multiple email addresses using mail() function.

But you didn''t read the most important part - and it was in bold! -

电子邮件来自mysql数据库表。
The emails are from a mysql database table.


从MySQL数据库中检索地址非常简单。你只需要构建一个SQL查询来选择它们(一个简单的SELECT查询应该这样做,但我真的不知道你的数据库是否足以说明这一点),并使用 mysql_query 函数来执行它。然后,您只需遍历结果并为每个结果发送一封电子邮件。 (该手册有很好的例子,说明它是如何工作的。)


如你已经知道如何发送电子邮件,这应该是相当直接的。如果您遇到任何问题,请在此处发布您的代码,我们将尝试帮助解决这些问题。


PS

如果您不熟悉PHP中的数据库交互阅读几本教程可能是个好主意。 PHP和MySQL可能是互联网上写得最多的软件组合之一,所以你应该毫不费力地找到你喜欢的东西:)
Retrieving the addresses from the MySQL database is fairly simple. You just need to build a SQL query that will select them all (a simple SELECT query should do, but I don''t really know you database well enough to say that for sure), and use the mysql_query function to execute it. Then you just loop through the results and send an email for each one. (The manual has excellent examples that show how that works.)

And as you already know how to send an email, this should be fairly straight forward. If you run into any problems, post your code here and we will try to help solve them.

P.S.
If you are new to database interaction in PHP, it may be a good idea to read through a couple of tutorials. PHP and MySQL is probably one of the most written about software combo on the internet, so you should have no trouble finding something you like :)