PHP and MySQL email help !!

hi everyone ! im new to php script, hope u guys able to help me. Thank you in advance. Im using localhost xampp, i have activate my smtp and set smtp_port to 25 , smtp = localhost.

when i run the script , error message show:

Notice: Undefined variable: email in C:\xampp\htdocs\sendmymail.php on line 54

Notice: Undefined index: in C:\xampp\htdocs\sendmymail.php on line 54

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:\xampp\htdocs\sendmymail.php on line 56
newsletter sent to:

here is my php script, i have highlighted line 56 & 54 :

<?php include ("ch19_include.php"); if (!$_POST) { //haven't seen the form, so display it echo " Send a Newsletter

Send a Newsletter

<input type=\"text\" name=\"subject\" size=\"30\"

Mail Body:

"; } else if ($_POST) { //want to send form, so check for required fields if (($_POST["subject"] == "")|| ($_POST["message"] == "")) { header("Location: sendmymail.php"); exit; } //connect to database doDB(); if (mysqli_connect_errno()) { // if connection fails, stop script execution printf("Connect failed: %s\n", mysqli_connect_error()); exit(); } else { //otherwise, get emails from subscribers list $sql = "SELECT email FROM subscribers"; $result = mysqli_query($mysqli, $sql) or die(mysqli_error($mysqli)); //create a From: mailheader $mailheaders = "From: Your Mailling List "; //loop through results and send mail while ($row = mysqli_fetch_array ($result)) { set_time_limit(0); $email=$row ["$email"]; mail("email", stripslashes($_POST["subject"]), stripslashes($_POST["message"]), $mailheaders); echo "newsletter sent to: ".$email."
"; } mysqli_free_result($result); mysqli_close($mysqli); } } ?>

Here are lines 54-56 from your code:
$email=$row ["$email"];
mail(“email”, stripslashes($_POST[“subject”]),
stripslashes($_POST[“message”]), $mailheaders);

In line 54, you probably meant this:
[php]$email=$row [“email”];[/php]

In line 55/56, you need to change “email” to $email. And the error message “Failed to connect…” means that you need to check your SMTP settings.

thank you so much ;D
problem solved :-*

Sponsor our Newsletter | Privacy Policy | Terms of Service