PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
I have created from that is supposed to allow you to enter and send a message, and that part works, but I want to be able to add some formatting, which is where I run into trouble. Can this not be done from a form?
// get email from database
$sql = "SELECT email FROM subscribers";
$result = mysql_query($sql,$conn) or die(mysql_error());
// create a from mail header
$headers = "From: xxx <xxx@xxx.com>\n Content-Type: text/html\r\n";
// loop through results and send mail
while ($row = mysql_fetch_array($result)) {
set_time_limit(0);
$email = $row['email'];
mail($email, stripslashes($_POST[subject]), stripslashes($_POST[message]),
$headers);
echo "newsletter sent to: $email<br>";
}
It might be the way that you are not wrapping your array indexes in quotes which is causing PHP to not like your code. Otherwise, it should run as it is.
What kind of server are you on? It might have to do with the \r\n in the header. You might also want to look at Swiftmailer as a mailing tool. It is absolutely awesome and written by our very own d11wtq.
mjmacarty wrote:Cool. I am figuing it all out. I thought it was a PHP library extension like gd...
It's a library, but written with PHP code so all you have to do is place it on the server and inlcude the relevant files. The documentation (hopefully improved soon ) explains how to get up and running
Follow the simplest of examples from one of the two sets of documentation and you will be well on your way to using it efficiently. If not, post back and I can reply with some sample, easy, swift tests.
Thanks guys. I am still playing with Swift, but I got some thing to work that was much more, shall we say, basic. But I don't know why this should work. HTML came through just fine when I concatenated the Content-Type... with the From email address.
mjmacarty wrote:Thanks guys. I am still playing with Swift, but I got some thing to work that was much more, shall we say, basic. But I don't know why this should work. HTML came through just fine when I concatenated the Content-Type... with the From email address.