webForumDet fria alternativet

PHP Mail fråga!

2 svar · 376 visningar · startad av fatepower

fatepowerMedlem sedan feb. 200726 inlägg
#1

Ja först.. Jag har postat det här förut i ett engelskt forum så det är därför de är på engelska. Ber om ursäkt för det men orkade inte översätta allting igen. Jag fick inget svar förut men detta borde ju inte vara så svårt tycker jag, eller för mig är det svårt eftersom jag inte är riktigt inne med hur att sända mail i en svärm med 50 mail åt gången. Iaf så här lyder meddelandet:

Hi!

Im running a mail script on my server but when i shall send emails to all my users like 3000 i can only send like 200 emails then it returns with a error.
Exactly the same as this example:

I am working on a job board for a client and i am trying to do a mass email to all jobseekers(there are currently over 1000 jobseekers).
When i try to send out emails to just some of the jobseekers, it works fine. But when i try to send out emails to all the jobseekers, i am getting the following error:

Warning: mail() [function.mail]: could not execute mail delivery program '/usr/sbin/sendmail -t -i' in /home/ployjam/public_html/admin/emailall.php on line 63

Warning: mail() [function.mail]: could not execute mail delivery program '/usr/sbin/sendmail -t -i' in /home/ployjam/public_html/admin/emailall.php on line 63

Warning: mail() [function.mail]: could not execute mail delivery program '/usr/sbin/sendmail -t -i' in /home/ployjam/public_html/admin/emailall.php on line 63

Warning: mail() [function.mail]: could not execute mail delivery program '/usr/sbin/sendmail -t -i' in /home/ployjam/public_html/admin/emailall.php on line 63

Warning: mail() [function.mail]: could not execute mail delivery program '/usr/sbin/sendmail -t -i' in /home/ployjam/public_html/admin/emailall.php on line 63

Warning: mail() [function.mail]: could not execute mail delivery program '/usr/sbin/sendmail -t -i' in /home/ployjam/public_html/admin/emailall.php on line 63

Warning: mail() [function.mail]: could not execute mail delivery program '/usr/sbin/sendmail -t -i' in /home/ployjam/public_html/admin/emailall.php on line 63

Anyway when i contacted my server admin of the VPS he replied:

Thank you. Yes, I understand the issue. I also had a word with our system administrators and the reason for this has been found. The maximum simultaneously running user processes allowed by the system per VPS node are as follows:

regular 480

This is a restriction we would not change from a security and performance point of view.

You can either:
- re-write your script to send the messages in pack of 150 for instance.
- find a ready-to-use script to do so.

Well so now my question is. Does anyone knows how to rewrite this email function so it can send the mails in a loop, i mean send like 50 email at one time and then send another 50 emails?

Heres the script (emailtousers.php):

<?php
require_once("functions.php");
require_once("config.php");

$readyto=(isset($_POST["readyto"])?$_POST["readyto"]:"sa");
$readyto1=(isset($_POST["readyto1"])?$_POST["readyto1"]:"sa");
$kullan=(isset($_POST["kullan"])?$_POST["kullan"]:3);
$konu=(isset($_POST["konu"])?$_POST["konu"]:"Subject!");
$mailbolumu=(isset($_POST["mailbolumu"])?$_POST["mailbolumu"]:"Mail Body!");

$count=0;
block_begin("Email to Users");
?>
<center>
<TABLE width=20% class="lista">
<TR>
<TD align="center" class="header"><? echo "E-Mail to Users"; ?></TD></TR>
<TR><TD align="center" class="blocklist">
<?php
print("<form method=post action=admincp.php?user=".$CURUSER["uid"]."&code=".$CURUSER["random"]."&do=emailtousers>");
?>
<!-- <form method=post action="admincp.php?user=<?php echo $CURUSER["uid"]; ?>&code=<?php echo $CURUSER["random"]; ?>&do=emailtousers"> -->
<!-- <form method=post action="admincp.php?user=".$CURUSER["uid"]."&code=".$CURUSER["random"]."&do=emailtousers"> -->
</TD></TR>
<tr>
<td>
<b>Subject </b><input name="konu" type="text" id="konu" size="60" maxlength="60" />
</td>
</tr>
<tr>
<td>
<b>Mail</b><br />
<textarea name="mailbolumu" cols="57" rows="5" id="mailbolumu"></textarea>
</td>
</tr>
<tr>
<td align="center" class="blocklist">
User Group : <!Dropdown added by miskotes>

         <?
         print("<select name=\"kullan\">");
         print("<option value=0".($level==0 ? " selected=selected " : "").">".ALL."</option>");
         $res=mysql_query("SELECT id,level FROM users_level WHERE id_level>1 ORDER BY id_level");
         while($row=mysql_fetch_array($res))
         {
             $select="<option value='".$row["id"]."'";
             if ($level==$row["id"])
                $select.="selected=\"selected\"";
             $select.=">".$row["level"]."</option>\n";
             print $select;
         }
         print("</select>");
         ?>

<!End dropdown>

</td>
</tr>
<TR><TD align="center" class="lista">
<input type="submit" name="readyto" value="Send Email"><input name="readyto1" type="submit" id="readyto1" value="Send Activation Mail"></td></tr></form></table><br>
</center>
<?php
if ($readyto=="Send Email") {
?>
<TABLE width=100% class=lista cellpadding=0 cellspacing=0>
<TR><TD align="center" height="20px" class="block"><b>Emailed Users USER GROUP : <? echo ($kullan==0?"ALL":$kullan) ?></b></TD></TR></table>
<center>
<?php
if ($kullan==0) {
$q=mysql_query("SELECT users.id as id, username, random, email, language, downloaded, uploaded, level, UNIX_TIMESTAMP(joined) as joined, UNIX_TIMESTAMP(lastconnect) as lastconnect FROM users LEFT JOIN users_level ON users.id_level=users_level.id ORDER BY (uploaded / downloaded) ASC");
}
else
{
$q=mysql_query("SELECT users.id as id, username, random, email, language, downloaded, uploaded, level, UNIX_TIMESTAMP(joined) as joined, UNIX_TIMESTAMP(lastconnect) as lastconnect FROM users LEFT JOIN users_level ON users.id_level=users_level.id where (users.id_level='".$kullan."') ORDER BY (uploaded / downloaded) ASC");
}
while ($user=mysql_fetch_object($q)) {
if ($user) {
echo "<b>".$user->username."</b> emailed!<br>";
mail($user->email,$konu,$mailbolumu,"From: PantheraBits <email@siteemail.com>");
   $count++;
}
}

echo "<br><br> Found <b>".$count."</b> users and emailed!</b>";

}
if ($readyto1=="Send Activation Mail") {
if ($kullan==0) {
$q=mysql_query("SELECT users.id as id, username, random, email, language, downloaded, uploaded, level, UNIX_TIMESTAMP(joined) as joined, UNIX_TIMESTAMP(lastconnect) as lastconnect FROM users LEFT JOIN users_level ON users.id_level=users_level.id ORDER BY (uploaded / downloaded) ASC");
}
else
{
$q=mysql_query("SELECT users.id as id, username, random, email, language, downloaded, uploaded, level, UNIX_TIMESTAMP(joined) as joined, UNIX_TIMESTAMP(lastconnect) as lastconnect FROM users LEFT JOIN users_level ON users.id_level=users_level.id where (users.id_level='".$kullan."') ORDER BY (uploaded / downloaded) ASC");
}
while ($user=mysql_fetch_object($q)) {
if ($user) {
//echo "www.pantherabits.com/account.php?act=confirm&confirm=".$user->random."&language=".$user->language." <br>";
echo "<b>".$user->username."</b> emailed!<br>";
mail($user->email,"activation subject","Activation link       http://www.yoursite.com/account.php?act=confirm&confirm=".$user->random."&language=".$user->language,"From: pantherabits <email@yoursite.com>");
   $count++;
}
}
echo "<br><br> Found <b>".$count."</b> users and emailed!</b>";

}
   block_end();

?>

I would be very glad if anyone could help me with this one :)
Thanks in advice and sorry 4 my bad gramma.

Cheers

UrMeMedlem sedan apr. 2001797 inlägg
#2

Du får loopa igenom och lägga till e-mail adresser till BCC (dolda kopior) och sedan kontrollera när du har loopat 50 gånger skickar du iväg mailet, och tömmer variabeln för BCC och lägger till nya tills 50 till ligger i BCC etc etc.

Hinner inte kolla igenom scriptet och koda ihop det, men sök på google efter "php mail, bcc, headers" eller något så lär du få upp exempel på det.

Eller så söker du på phpportalen.net för där vet jag att det finns exempel i deras forum.

fatepowerMedlem sedan feb. 200726 inlägg
#3

Tackar så mkt jag har inte en blekaste aning över hur jag gör dessa loopar.
Vore trevligt med lite hjälp med får söka lite :P

Genererad på 387 ms · cache AV · v20260730165559-full.f96bc7eb