我一直在研究這個,但不能得到答案。 我有一個表單將信息發送到我的數據庫,我也希望信息轉到存儲在數據庫中的表中的列中的電子郵件地址。繼承人的代碼,我只是玩弄,看看我可以做一個SELECT查詢,但它wouldnt工作,也Iknow,在發送電子郵件的作品時,我手動UT斯達康一個地址到我的「setTo」將表格信息發送到存儲在數據庫中的電子郵件
require 'mail/class.simple_mail.php';
$mailer = new SimpleMail();
$comments = $_REQUEST['comments'];
$time = $_REQUEST['time'];
$date = $_REQUEST['date'];
$place = $_REQUEST['place'];
$email = "SELECT email FROM bridesmaids";
$message = "<strong>This is an email from the bride to you the bridesmaids, here is the information on the next dress fitting<br />".$date." ".$time." ".$place." ".$comments." </strong>";
$send = $mailer->setTo('$email', 'Your Email')
->setSubject('Dress Fitting')
->setFrom('[email protected]', 'Domain.com')
->addMailHeader('Reply-To', '[email protected]', 'Domain.com')
->addMailHeader('Cc', '[email protected]', 'Bill Gates')
->addGenericHeader('Content-Type', 'text/html; charset="utf-8"')
->setMessage($message)
->setWrap(100)
->send();
echo ($send) ? 'Your Email has been sent to your bridesmaids' : 'Could not send email';
變量不會在單引號下解析,您需要刪除它們。寫這樣的..'$發送= $郵件程序 - > setTo($電子郵件,'您的電子郵件')' –
好吧,謝謝你的迴應,但我不認爲我的SELECT查詢選擇表中的enails工作,有任何想法嗎? – user3464354
你不能直接使用你的SELECT查詢作爲你的$ email變量 –