Jump to content

Recommended Posts

Hello all, I have a mail script that I am currently using and for the most part it seems to work well. In a nutshell it grabs the email addys from a MYSQL table and emails all the recipients...so I thought. My two personal emails are in the table (gmail & bellsouth.net) I get the emails with my gmail account but nothing in my bellsouth.net account. I looked in the spam folder and nothing. I wonder how many people in my table are not getting my emails? Can anyone help shed some light on this as well as some pointers to optimize my script.

 

here is my script, I omitted the connection for its not really necessary.

<?php
// includes
include('includes/PXS_Conf.php');

// open database connection
$connection = mysql_connect($host, $user, $pass) or die ('Unable to connect to MySql server!');

// select database
mysql_select_db($db) or die ('Unable to select database!');
$sql_state = mysql_query("SELECT state FROM PXS_Newsletter WHERE verified = 1 GROUP BY state") or die (mysql_error());
$sql_gender = mysql_query("SELECT gender FROM PXS_Newsletter WHERE verified = 1 GROUP BY gender") or die (mysql_error());

// form not yet submitted
// display initial form
if (!$_POST['submit'])
{
?>
<table cellpadding="5" cellspacing="5" class="table1">
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="POST">

<tr>
<tr>
    <td valign="top" class="text5">Subject</td>
    <td><input name="txtsubject" type="text" class="table2" id="txtsubject" size="50" maxlength="250"></td>
</tr>
<tr>
    <td valign="top" class="text5">Email Body</td>
    <td valign="top" class="text5"><textarea name="txtbody" cols="47" rows="10" class="table2" id="txtbody"></textarea></td>
</tr>
<tr>
  <td colspan="2" valign="top" class="text5"><input name="submit" type="submit" id="submit" value="Submit">
    <input type="reset" name="Submit2" value="Reset"></td>
  </tr>
</form>
</table>
<?php
}
else
{
    // set up error list array
    $errorList = array();
    
    $msgsubject = $_POST['txtsubject'];
    $msgbody = $_POST['txtbody'];
$state = trim($_POST['ssl_state']);
$gender = trim($_POST['ssl_gender']);	

    // validate text input fields
    if (trim($_POST['txtsubject']) == '') 
    {$errorList[] = 'Invalid entry: Message Subject';}

    if (trim($_POST['txtbody']) == '') 
    {$errorList[] = "Invalid entry: Message Body";}

   
    // check for errors
    // if none found...
    if (sizeof($errorList) == 0)
    {
        // generate and execute query
        $query = mysql_query("SELECT email FROM PXS_Newsletter WHERE verified = 1") or die (mysql_error());
        while($row = mysql_fetch_row($query)){
	$email = $row[0];

// send email
    $headers = "Reply-To:".$fromname."<".$fromaddress.">".$eol;
mail($email, $msgsubject, $msgbody, $headers);}

// print result
echo '<center><span class="text6">Message sent!</span></center>';

        // close database connection
        mysql_close($connection);
    }
    else
    {
        // errors found
        // print as list
        echo 'The following errors were encountered:'; 
        echo '<br>';
        echo '<ul>';
        for ($x=0; $x<sizeof($errorList); $x++)
        {
            echo "<li>$errorList[$x]";
        }
        echo '</ul>';
    }
}
?>

Link to comment
https://forums.phpfreaks.com/topic/87248-mail-script-tweaking/
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.