【发布时间】:2014-04-16 12:03:09
【问题描述】:
我正在尝试使用 PHP 发送电子邮件,但我希望收件人是存储在我的数据库中的电子邮件。
这是一些代码
$send = $mailer->setTo('email@example.com', 'Your Email')
->setSubject('Example')
->setFrom('example@email.com', 'test')
->addMailHeader('Reply-To', 'example@test.com', 'test')
->addMailHeader('Cc', 'edonaghy--@hotmail.co.uk', 'test')
->addGenericHeader('Content-Type', 'text/html; charset="utf-8"')
->setMessage($message)
->setWrap(400)
->send();
这是正在发送的电子邮件,它是从用户填写的表格中提取的
mysql_select_db("lr", $con);
require 'mail/class.simple_mail.php';
$mailer = new SimpleMail();
$comments = $_REQUEST['comments'];
$time = $_REQUEST['time'];
$date = $_REQUEST['date'];
$place = $_REQUEST['place'];
$message = "<strong>This is an email from the bride to you the bridesmaids, here is the information on the next dress fitting<br />Date:".$date."<br />Time: ".$time."<br /> Place:".$place."<br />Any other comments: ".$comments." </strong>";
if ($send) {echo 'Your Email has been sent';}else {
echo 'An error occurred. We could not send email';
【问题讨论】:
-
好的,所以你有一些代码可以发送电子邮件。您是否有任何代码可以连接并查询您的数据库?
-
首先将有效数据放入其中并进行测试。这已经表明邮寄过程是否运作良好。然后,您将需要编写一些代码来从数据库中获取数据。如果您遇到该代码时遇到问题,请返回并将其展示给我们,以便我们提供帮助。
-
是的,我测试了它,它只在发送到一个手动输入的电子邮件时就可以工作。
-
所以你正在尝试从数据库中查询数据.. 那就去做吧。你不是说发生了什么错误,你基本上是在要求我们为你编程,它不是那样工作的。如果您能告诉我们实际问题是什么,我们可以给您提示。
-
在您的第二个代码块中,
$send定义在哪里?