email function is not working..!!!

A

Anonymous

Guest
i have created an email function to send an email from php codes.
i've got the error message like below when i tried to send an email.
i'm really dont know where to change my codes.
can anybody help me???


Notice: Undefined offset: 1 in c:\easyphp1-7\www\el\sendemail.php on line 31

Notice: Undefined offset: 2 in c:\easyphp1-7\www\el\sendemail.php on line 32

Warning: 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:\easyphp1-7\www\el\sendemail.php on line 36
newsletter sent to : rb_ed@yahoo.com
Completed sending emails

******************************************************************************************************
below is my codes:

<?php

//make a connection
$host="127.0.0.1";
$name = "el";
$pass = "";
$dbname = "el";

// Connect to Database and select the database to use
$dbi = mysql_connect($host, $name, $pass)

or die("I cannot connect to the database. Error :" . mysql_error());
mysql_select_db($dbname,$dbi);


$sql_query = "SELECT email FROM email";
$result = mysql_query($sql_query) or die("cannot execute query");
$header = "From : me";
//loop through rows
while ($row = mysql_fetch_array($result))
{
$address = $row[0];

//mail function requires email address($address)
//The subject($subject) , the message ($body) and
//the $header info
mail($address ,$subject , $body , $header);

//display a message confirming email has been sent
echo ("newsletter sent to : $address<br>");
}
echo ("Completed sending emails");

?>
 
Hunn... maybe you need to change your mail server from "localhost" to something like: mail.yourdomain.com.
 
but..i dont know where to change it?
is it in the php.ini file??
i'm really blur on this matter...dont know what to do!!!
 
change the host IP to what gesf suggested, this line

Code:
$host="127.0.0.1";
 
hmm..i've already changed the setting in php.ini...but still got the same error!! :( :help:
 
:help: i need your help guys..!!what i am suppose to do with this error??how to make this email function working well???
 
Check for your sendmail program and than see if the sendmail_path is ok.
Ex.:
Code:
sendmail_path=/usr/sbin/sendmail -t -i
 
fixaded said:
:help: i need your help guys..!!what i am suppose to do
with this error??how to make this email function working well???
Are you sure what you are have a SMTP?
telnet <mailserver>: 25
see what you get, if nothing when you are not have a service
Windows: netstat -A
*nix: use 'top' or 'ps' command shell

2 gesf: no matter what exaclty mail agent u use, mean what process is run!
 
Back
Top