PHP Mailing list!

I have created a simple php mailing script seeing a tutorial. But the problem is the script works but the email doesn’t go. I got stuck with the mail host thingy. The guy uses his mailhost code like

ini_set(“SMTP”, “mailhost.*******.co.uk”);

So I got stuck with this, what should be my mailhost, I have a domain with hosting. The provider just gave me three addresses which are

cpanel.*******.com
webmail..com
ftp.
.com

So how should I write the code, and I also got 10 POP3 email, i made some email accounts with it but how can I send the emails?

here is my code for index.php and send.php:

<?php
require ('connect.php');


echo "<h1>Mailing List</h1> Send to <p>";

echo "<form action='send.php' method='GET'>";

//setup variable
$mailcount = 0;
$namecount = 0;
$get = mysql_query("SELECT * FROM mailinglist where send='1'");

while ($getrow = mysql_fetch_assoc($get))
{
echo "<input type = 'checkbox' name='mail_".$mailcount++."' value'".$getrow['email']."' CHECKED><br>".$getrow['firstname']." ".$getrow['lastname']." (".$getrow['email'].")<br>";
}





echo "</form>"


?>

here is send.php


<?php


require ('connect.php');

//change php.ini SMTP file
ini_set("SMTP", "mailhost.*******.co.uk");  <-------This line, please help


//standard mail header

$headers = "foodecrp@split.starhostbd.com";

//get message

//loop through
for($x=0; $x<count($_GET);$x++)
{
   if ($_GET["mail_$x"])
   {
		
		
	//mail setup
		$to = $_GET["mail_$x"];
		$subject = "Newsletter";
		$body = "Dear ".$_GET["name_$x"]."
		\
\
 $message \
\

		FoodieCorp.
		";
		
		mail($to, $subject, $body, $header);
		
		
   }
	
}



echo "All email has been processed.";





?>

why need to change your mailhost?
if you have a hosting, the mailhost configuration should be already setup.

try remove the line ini_set(“SMTP”, “mailhost.*******.co.uk”);

Well I meant what should I write in that line? any address of mine? I tried removing the ini set line but the emails doesnt go, but the message appears all emails has been processed

you need to remove the line ini_set, as this will overide the default mail setings for php.

your script will always tell you the mail has been processed as it is not checking only printing.

You also need to have more headers for most SMTP servers to accept to send your mail

change send.php for this and try


<?php
require ('connect.php');
$badmail = 0;
$goodmail =  0; 

//standard mail header
 
$headers = "MIME-Version: 1.0\\r\
"; 
$headers .= "Content-type: text/html; charset=iso-8859-1\\r\
"; 
$headers .= "From: you@yourdomain.com\\r\
";  // change this address
$headers .= "Reply-To: you@yourdomain.com\\r\
";  // and this one
$headers .= "X-Priority: 1\\r\
"; 
$headers .= "X-MSMail-Priority: High\\r\
"; 
$headers .= "X-Mailer: PHP \\r\
";
  
//get message
 
//loop through
for($x=0; $x<count($_GET);$x++)
{
   if ($_GET["mail_$x"])
   {
 
 
//mail setup
$to = $_GET["mail_$x"];
$subject = "Newsletter";
$body = "Dear ".$_GET["name_$x"]."
\
\
 $message \
\

FoodieCorp.
";
 
if (mail($to, $subject, $body, $headers)){
$goodmail++;
}else{
$badmail ++;
}
 
 
   }
 
}
 
 
 
echo "$goodmail emails sent - $badmail emails not sent.";
 
?>

Tried man doesn’t work. says 2 emails sent but I get nothing in my inbox but failure message in my header email outbox. Okay I got into cpanel and saw some Outgoing mail server and outgoing mail server (SSL) settings as below:


Manual Settings
Mail Server Username: foodecrp
Incoming Mail Server: mail.******.com
Incoming Mail Server: (SSL) split.bd.com
Outgoing Mail Server: mail.
.com (server requires authentication) port 466
Outgoing Mail Server: (SSL) split.*******bd.com (server requires authentication) port 465
Supported Incoming Mail Protocols: POP3, POP3S (SSL/TLS), IMAP, IMAPS (SSL/TLS)
Supported Outgoing Mail Protocols: SMTP, SMTPS (SSL/TLS)

i tried with these Outgoing mail server on Php ini set in my 1st send.php file apart from yours with these, still I get no emails but failure messages.

[I][B]This message was created automatically by mail delivery software.

A message that you sent could not be delivered to one or more of its
recipients. This is a permanent error. The following address(es) failed:

on@split.starhostbd.com
Unrouteable address

------ This is a copy of the message, including all the headers. ------

Return-path: <foodecrp@split..com>
Received: from foodecrp by split.
.com with local (Exim 4.69)
(envelope-from <foodecrp@split.********.com>)
id 1S0ObS-0001K2-9D
for on@split.********.com; Wed, 22 Feb 2012 20:39:54 -0600
To: on@split.********.com
Subject: Newsletter
X-PHP-Script: *.com/send.php for 99.43.202.106
Message-Id: <E1S0ObS-0001K2-9D@split.
.com>
From: foodecrp@split.********.com
Date: Wed, 22 Feb 2012 20:39:54 -0600[/B][/I]

Please advise!!