Newsletter and smtp
| From: | Remember14a at aol dot com | Date: | Thu, 09 Sep 2004 09:47:46 +0000 |
| Subject: | Newsletter and smtp | ||
| Groups: | php.db | ||
| Request: | Send a blank email to php-db+get-36131@lists.php.net to get a copy of this message | ||
Dear friends,
While sending newsletter, using mailing list, php script is able to connect
to database, retrieve emails, however is unable to send newsletter or email.
I am using localhost.
I have SMTP installed on local machine.
Any guidance
------------------------------------------------------------------------
Warning: mail(): SMTP server response: 554 5.7.1 (IPT:OA) Use port 587 to
send mail from your AOL screen name.
http://postmaster.info.aol.com/errors/554iptoa.html
in C:\HOME\doctorbush\sendmymail.php on line 44
newsletter sent to: mamu@aol.com
Warning: mail(): SMTP server response: 554 5.7.1 (IPT:OA) Use port 587 to
send mail from your AOL screen name.
http://postmaster.info.aol.com/errors/554iptoa.html
in C:\HOME\doctorbush\sendmymail.php on line 44
newsletter sent to: ice101@aol.com
Warning: mail(): SMTP server response: 554 5.7.1 (IPT:OA) Use port 587 to
send mail from your AOL screen name.
http://postmaster.info.aol.com/errors/554iptoa.html
in C:\HOME\doctorbush\sendmymail.php on line 44
newsletter sent to: globe@aol.com
----------------------------------------------------------------------
script to send mail
----------------------------------------------------
<?php
if ($_POST[op] != "send") {
//haven't seen the form, so show it
print "
<HTML>
<HEAD>
<TITLE>Send a Newsletter</TITLE>
</HEAD>
<BODY>
<h1>Send a Newsletter</h1>
<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
$conn = mysql_connect("localhost", "", "") or die(mysql_error());
mysql_select_db("b",$conn) or die(mysql_error());
//get emails from subscribers list
$sql = "select email from subscribers1";
$result = mysql_query($sql,$conn) or die(mysql_error());
//create a From: mailheader
$headers = "<globalvoice101@aol.com>\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>";
}
}
?>