I am trying to setup PHP to send email, from a project in Sams - Teach
Yourself PHP, MySQL and Apache in 24 Hours.chm. (newbie fodder)
The program appears to run OK but the email does not get delivered. The
program shows the email addresses that the email was supposedly sent to.
My email progress indicator shows the mail going out but it never gets to any of
it's destinations.
I think I have configured PHP 5.0.4, and Apache 2.0.54 correctly. Why else would
the email show that it's sending???
I also have MySQL 5.04. but I don't see anything in MySQL to set for email.
I am confused with:

; For Win32 only.
sendmail_from =

and

DEFAULT_SENDMAIL_PATH

in php.ini. How should these be set?

Here is the listing. Can anyone see something wrong here?

Any help will be greatly appreciated. TIA

<?php
if ($POST[op] != "send") {
//haven't seen the form, so show it
print "
<HTML>
<HEAD>
<TITLE>Send a Newsletter</TITLE>
</HEAD>
<BODY>
<h2>Send a Newsletter</h2>
<form method=\"post\" action=\"$
SERVER[PHP_SELF]\">
<P><strong>Subject:</strong><br>
<input type=\"text\" name=\"subject\" size=30></p>
<P><strong>Mail Body:</strong><br>
<textarea name=\"message\" cols=50 rows=10 wrap=virtual></textarea>
<input type=\"hidden\" name=\"op\" value=\"send\">
<p><input type=\"submit\" name=\"submit\" value=\"Send It\"></p>
</FORM>
</BODY>
</HTML>";

} else if ($POST[op] == "send") {
//want to send form, so check for required fields
if (($
POST[subject] =="") || ($_POST[message] == "")) {
header("Location: sendmymail.php");
exit;
}
// Connect to database, and select table.
include ("../docs/DB01.inc");

//get emails from subscribers list
$sql = "select email from subscribers";
$result = mysql_query($sql,$conn) or die(mysql_error());

//create a From: mailheader
$headers = "From: Your Mailing List <xxxxxxxx@addrress.net>\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);
print "newsletter sent to: $email<br>";
}
}

?>

Output...
newsletter sent to: xxxxxxxxx@netzero.net
newsletter sent to: xxxxxxxxx@yahoo.com
newsletter sent to: xxxxxxxxxs@adelphia.net
newsletter sent to: xxxxxxxxxs@hotmail.com

(names replaced with x)

    Logic Rules wrote:

    mail("$email", stripslashes($POST[subject]), stripslashes($POST[message]), $headers);
    print "newsletter sent to: $email<br>";
    }
    }

    ?>

    Output...
    newsletter sent to: xxxxxxxxx@netzero.net
    newsletter sent to: xxxxxxxxx@yahoo.com
    newsletter sent to: xxxxxxxxxs@adelphia.net
    newsletter sent to: xxxxxxxxxs@hotmail.com

    (names replaced with x)

    So we don't know who you're spamming? :p

    Or maybe it's legit, and fjbivings is your real name? :queasy: :eek: Have I insulted you? It wasn't really intentional, if so.

    Mail issues can be big if you are a newb. Look at the code I quoted. There's no test to see if the mail() function returns good or bad. So of course it will print "newsletter sent", even if it's NOT being sent. So that's the first problem.... 😉

      Well that takes care of the output but what about getting the email to go?
      No insult but you could edit out my name.

        EMAIL CONFIG FOR NEWBIES...

        PHP.INI

        [mail function]
        ; For Win32 only.
        SMTP = SMTP.NETZERO.NET ** SMTP from your ISP **
        smtp_port = 25

        ; For Win32 only.

        sendmail_from = tuna@fish.net ** Your email **

        Apache HTTP.CONF

        ServerAdmin: Your address, where problems with the server should be

        e-mailed. This address appears on some server-generated pages, such

        as error documents. e.g. admin@your-domain.com

        #
        ServerAdmin abcdef@ABCDEF ** Not quite sure of the logic for this
        but if your domain is ABCDEF, I guess The admin is abcdef. But it works!
        **

        Optionally add a line containing the server version and virtual host

        name to server-generated pages (internal error documents, FTP directory

        listings, mod_status and mod_info output etc., but not CGI generated

        documents or custom error documents).

        Set to "EMail" to also include a mailto: link to the ServerAdmin.

        Set to one of: On | Off | EMail

        #
        ServerSignature EMail ** My Choice is EMail. That works for me! **

        Be sure to restart your Server!!!

        Only a couple patches of hair missing 🙂

          Make sure you have your SMTP server path configured in PHP.INI, and the sendmail_from line should be "me@localhost".

          Under *nix, write the path to your sendmail program.

            Write a Reply...