twilitegxa Posted August 24, 2008 Share Posted August 24, 2008 Here is the error I'm receiving: Warning: mail() [function.mail]: Failed to connect to mailserver at "localhost" port 25, verify your "SMTP" and "smtp_port" setting in php.ini or use ini_set() in C:\wamp\www\files\sendmymail.php on line 46 How do I adjust these settings? Or is there something else I need to do? Here is the code: <?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", "root", "") or die(mysql_error()); mysql_select_db("smrpg",$conn) or doe(mysql_error()); //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 <twilitegxa@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 />"; } } ?> There doesn't appear to be any problems with the code itself, but just in case. I receive the error message but it also will say: newsletter sent to twilitegxa@aol.com (that's the e-mail address I have in the database), but when I check my e-mail to see if the test worked, but it doesn't actually send, which is I guess why I get the error. Can anyone tell me what to change and how? Quote Link to comment Share on other sites More sharing options...
Caesar Posted August 24, 2008 Share Posted August 24, 2008 Some hosts block port 25 or the mail() function. Is this a shared hosting plan you're using to test? Quote Link to comment Share on other sites More sharing options...
twilitegxa Posted August 24, 2008 Author Share Posted August 24, 2008 I don't know. How could I tell? I am using the WampServer package to test in, with phpMyAdmin. Quote Link to comment Share on other sites More sharing options...
DeanWhitehouse Posted August 24, 2008 Share Posted August 24, 2008 As far as i know the from email , must be registered on the host , unless you set the SMTP email somewhere else , for example by using PHPmailer. So you need to change the from email to one that is set up on the host. Quote Link to comment Share on other sites More sharing options...
Caesar Posted August 24, 2008 Share Posted August 24, 2008 As far as i know the from email , must be registered on the host , unless you set the SMTP email somewhere else , for example by using PHPmailer. So you need to change the from email to one that is set up on the host. Well not necessarily...but some mail providers like Yahoo! will flag the message as spam if the sending email is not hosted on the domain. They do a reverse DNS lookup on the sending address. So yeah...there's a chance the ISP or mail providers will flag as spam. Quote Link to comment Share on other sites More sharing options...
DeanWhitehouse Posted August 24, 2008 Share Posted August 24, 2008 I think it is , thats why the SMTP error is appearing, as when i tried sending emails via mail(); with my hotmail address, it wouldnt send, i contacted my host and they said it has to be one registered on the server. So i used PHPmailer, and set it in the SMTP settings. Quote Link to comment Share on other sites More sharing options...
twilitegxa Posted August 24, 2008 Author Share Posted August 24, 2008 What is PHPMailer? Quote Link to comment Share on other sites More sharing options...
DeanWhitehouse Posted August 24, 2008 Share Posted August 24, 2008 A php mailing application. Google it Quote Link to comment Share on other sites More sharing options...
Caesar Posted August 24, 2008 Share Posted August 24, 2008 It's dependent on whether or not a host allows it. I send emails fine, defining non-hosted addresses on my private dedicated servers. Never had an issue with email addresses that were not hosted locally. Quote Link to comment Share on other sites More sharing options...
DeanWhitehouse Posted August 24, 2008 Share Posted August 24, 2008 maybe because you are on private dedicated servers. Anyway , register an email with the host and try it, note* to use phpmailer, you need an email registered with the host. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.