SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Enthusiast
    Join Date
    Jan 2008
    Posts
    62
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question Loop a email from a database

    I currently use a php mailer to send emails to my student in the 6 different classes we have. When I pull the intire directory on 200+emails and send out the list it gets put in to junk mail 80% of the time. I was told because filters look for a certian number of contact or something to that nature.

    What I want to do is email one person every 10 seconds and have the code go through and send out untill the list is complete

    this is what I am working with so far I know it looks rough but it is a code I got some were else and have been playing with.

    PHP Code:

    $query 
    mysql_query("SELECT first_name, last_name, email FROM *"

    or die (
    mysql_error()); 

    $numrows=mysql_num_rows($query); 

    echo 
    "\n""$numrows emails are being sent out!"

    print_r($row); 

    while (
    $row mysql_fetch_array($query)) 

    $ams_admin "myemail"
    $subject "mysubject"
    $email $row['email']; 
    $sentto $row['first_name'] . " " $row['last_name']; 
    $message 
    what I am sending them in html format.
    "


    mail("$email""$subject""$message""From: $ams_admin\r\n"."Date: ".date("D, j M Y\ G:i:s -0500", )."\r\n""-f$ams_admin"); 

    sleep(10); 
    I am new at this but catch on quick the code above basically trys to explain what I am doing. pulls from database first_name, last_name, email and put it in the form then email 1 sleep 10 seconds then email again.

    I saw other people refering to a sendmail flag addition so the emails stop and does not repeat the list. where they set the field to 1.

    PHP Code:
    $query mysql_query("SELECT first_name, last_name, expiry_date, email FROM * WHERE sendmail_flag[=I set this field in the data table] ='1'"
    Please advise on what to do or let me know of a place that has script like this I can reference and learn more. I have looked but might of missed something

    Thank You

  2. #2
    SitePoint Enthusiast
    Join Date
    Apr 2006
    Posts
    49
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    there are a few reasons you'll get email flagged as spam. some tips to avoid are:

    firstly, use a valid email address as the from address.

    secondly, set up the spf dns record for the email address domain that you send the email from.

    thirdly, make sure your email doesn't have the characteristics of spam.

    sometimes looking at the email header will tell you exactly why your email has exceeded a spam threshold.

    i'm afraid this topic is so wide its difficult to say exactly what the reason for your email being sent to junk mail is.

  3. #3
    SitePoint Enthusiast
    Join Date
    Apr 2009
    Posts
    63
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    After looking over your code it looks like you're sending each email out individually - which is good, if it was a mass email that would most likely be the cause it getting caught as spam, but since it's not the reason then it's really hard to say without an email header. Also you might want to try a smpt auth type of php email script - that should help.

  4. #4
    SitePoint Member
    Join Date
    Mar 2008
    Location
    Leeds, UK
    Posts
    7
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I've had success in the past by adding "X-Priority: 10" as another header. Telling the email server that the message is low priority seems to allow it through more often.

  5. #5
    SitePoint Addict goodmast3r's Avatar
    Join Date
    Apr 2005
    Posts
    200
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Do you need to pause? sleep(10)? I think it is ok not to pause.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •