Игорь_Vasinsky
22.05.2013 - 09:20
решения есть почти всегда.
_____________
HTML, CSS (Bootstrap), JS(JQuery, ExtJS), PHP, MySQL, MSSql, Posgres, (TSql, BI OLAP, MDX), Mongo, Git, SVN, CodeIgnater, Symfony, Yii 2, JiRA, Redmine, Bitbucket, Composer, Rabbit MQ, Amazon (SQS, S3, Transcribe), Docker
sas543
31.05.2013 - 10:27
все, нашел решение этой проблемы )))Спасибо за помощь. Хотя вот еще какая проблема в этом коде , при отсылки на gmail.com письма попадают в спам, как решить эту проблему ????
Вот сам код
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Документ без названия</title>
</head>
<body>
<?
////////////////////////////////////////////////////////////////////////////////
ignore_user_abort(true);
set_time_limit (0);
ini_set('max_execution_time',0);
error_reporting(0);
$fileforlogs="log.txt";
////////////////////////////////////////////////////////////////////////////////
$action = $_POST['action'];
if ($action=="send")
{
$message = urlencode($message);
$message = ereg_replace("%5C%22", "%22", $message);
$message = urldecode($message);
$message = stripslashes($message);
$subject = stripslashes($subject);
}
?>
<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="-1" face="Verdana, Arial, Helvetica, sans-serif">
Ваш Email:</font></div></td>
<td width="18%"><font size="-3" face="Verdana, Arial, Helvetica, sans-serif">
<input type="text" name="from" value="<? if (isset($from)) echo($from) ?>" size="30">
<input type="checkbox" name="random_mail" onClick="javascript:document.getElementById('from').style.display=this.checked?'none ':'';">Случайные сообщений электронной почты
</font></td>
<td width="31%">
<div align="right"><font size="-3" face="Verdana, Arial, Helvetica, sans-serif">
Ваше имя:</font></div></td>
<td width="41%"><font size="-3" face="Verdana, Arial, Helvetica, sans-serif">
<input type="text" name="realname" value="<? print $realname; ?>" size="30">
<input type="checkbox" name="random_name" onClick="javascript:document.getElementById('realname').style.display=this.checked?' none':'';">Случайные имена
</font></td></tr>
<tr><td width="10%">
</td>
<td width="18%"></td>
<td width="31%">
<div align="right"><font size="-3" face="Verdana, Arial, Helvetica, sans-serif">
Вложить файл:</font></div></td>
<td width="41%"><font size="-3" face="Verdana, Arial, Helvetica, sans-serif">
<input type="file" name="file" size="30"></font></td></tr><tr><td width="10%">
<div align="right"><font size="-3" face="Verdana, Arial, Helvetica, sans-serif">Тема:</font></div>
</td><td colspan="3"><font size="-3" face="Verdana, Arial, Helvetica, sans-serif">
<input type="text" name="subject" value="<? print $subject; ?>" size="90">
<input type="checkbox" name="random_sabj" onClick="javascript:document.getElementById('subject').style.display=this.checked?'n one':'';">Случайные темы
</font></td>
<tr valign="top">
<td colspan="3"><font size="-3" face="Verdana, Arial, Helvetica, sans-serif">
<hr size="2" width="100%" align="right"><br>
<b>Сообщение:</b>
<br>
<textarea name="message" cols="60" rows="10"><? if (isset($message)) echo($message); Else echo("Clear this and put Message"); ?>
</textarea><br>
<input type="hidden" name="action" value="send">
<input type="submit" value="Начало рассылки">
</font></td>
<td width="41%"><font size="-3" face="Verdana, Arial, Helvetica, sans-serif">
<hr size="2" width="100%" align="left"><br>
<b>Список рассылки:</b>
<input type="checkbox" name="mails_from_file" onClick="javascript:document.getElementById('emaillist').style.display=this.checked?' ;none':'';document.getElementById('mailfilename').style.display=this.checked?' ;':'none';">Загрузить из файла
<br>
<input type="input" name="mailfilename" value="Имя файла" style="DISPLAY: none;">
<textarea name="emaillist" cols="30" rows="10"><? if (isset($emaillist)) echo($emaillist); Else echo("Снимите этот и положил список рассылки"); ?>
</textarea>
<br>
</font></td></tr></table>
</form>
<?
function s() {
$word="qwrtpsdfghklzxcvbnm";
return $word[mt_rand(0,strlen($word)-1)];
}
function g() {
$word="eyuioa";
return $word[mt_rand(0,strlen($word)-2)];
}
function c() {
$word="1234567890";
return $word[mt_rand(0,strlen($word)-3)];
}
function a() {
$word=array('wa','sa','da','qa','ra','ta','pa 39;,'fa','ga','ha','ja','ka','la','za','x a','ca','va','ba','na','ma');
$ab1=count($word);
return $wq=$word[mt_rand(0,$ab1-1)];
}
function o() {
$word=array('wo','so','do','qo','ro','to','po 39;,'fo','go','ho','jo','ko','lo','zo','x o','co','vo','bo','no','mo');
$ab2=count($word);
return $wq2=$word[mt_rand(0,$ab2-1)];
}
function e() {
$word=array('we','se','de','qe','re','te','pe 39;,'fe','ge','he','je','ke','le','ze','x e','ce','ve','be','ne','me');
$ab3=count($word);
return $wq3=$word[mt_rand(0,$ab3-1)];
}
function i() {
$word=array('wi','si','di','qi','ri','ti','pi 39;,'fi','gi','hi','ji','ki','li','zi','x i','ci','vi','bi','ni','mi');
$ab4=count($word);
return $wq4=$word[mt_rand(0,$ab4-1)];
}
function u() {
$word=array('wu','su','du','qu','ru','tu','pu 39;,'fu','gu','hu','ju','ku','lu','zu','x u','cu','vu','bu','nu','mu');
$ab5=count($word);
return $wq5=$word[mt_rand(0,$ab5-1)];
}
function name0() {return c().c().c().c();}
function name1() {return a().s();}
function name2() {return o().s();}
function name3() {return e().s();}
function name4() {return i().s();}
function name5() {return u().s();}
function name6() {return a().s().g();}
function name7() {return o().s().g();}
function name8() {return e().s().g();}
function name9() {return i().s().g();}
function name10() {return u().s().g();}
function name11() {return a().s().g().s();}
function name12() {return o().s().g().s();}
function name13() {return e().s().g().s();}
function name14() {return i().s().g().s();}
function name15() {return u().s().g().s();}
function randword()
{
$cool=array(1,2,3,4,5,6,7,8,9,10,99,100,111,666,1978,1979,1980,1981,1982,1983,1984,1985,1986,1987,1988,1989,1990,1991,1992,1993,1994,1995,1996,1997,1998,1999,2000,2001,2002,2003,2004,2005);
$func="name".mt_rand(0,15);
$func2="name".mt_rand(0,15);
switch (mt_rand(0,2))
{
case 0: return $func().$func2();
case 1: return $func().$cool[mt_rand(0,count($cool)-9)];
case 2: return $func();
default: return $func();
}
}
function randmail()
{
$domain=array('mail.com','hotmail.com','aol.com','microsoft.com', 39;yahoo.com','gmail.com','theglobeandmail.com','mail333.com','pmail. com','lycos.com','royalmail.com','dailymail.co.uk','apple.com', 39;imc.org','sun.com','hushmail.com','mozilla.org','worldemail.com 9;,'mailstart.com','cnn.com','operamail.com','almail.com','netsca pe.com','email.com','latinmail.com','bigmailbox.com','e-mps.org', 'internet.com','comcast.net','nova.edu');
$dom="@".$domain[mt_rand(0,29)];
return randword().$dom;
}
function randsabj()
{
$c=mt_rand(1,5);
$sabj="";
For($a=0;$a<=$c;$a++)
{
$sabj .= randword()." ";
}
return $sabj;
}
///////////////////////GET ENV//////////////////////////////////////////////////
if ($action=="send")
{
$from = $_POST['from'];
$subject = $_POST['subject'];
$message = $_POST['message'];
$emaillist = $_POST['emaillist'];
$random_mail = $_POST['random_mail'];
$random_name = $_POST['random_name'];
$realname = $_POST['realname'];
$replyto = $_POST['replyto'];
$random_reply = $_POST['random_reply'];
$subject = $_POST['subject'];
$random_sabj = $_POST['random_sabj'];
$mailfilename = $_POST['mailfilename'];
$mails_from_file = $_POST['mails_from_file'];
$log_to_file = $_POST['log_to_file'];
//////////////////////CHECK DATA////////////////////////////////////////////////
if ($random_mail!="on")
{ if (!$from)
{
echo("<font color=red>Введите свой email.</font>");
exit;
}
}
if ($random_name!="on")
{ if (!$realname)
{
echo("<font color=red>Вы должны ввести свое имя.</font>");
exit;
}
}
if ($random_sabj!="on")
{ if (!$subject)
{
echo("<font color=red>Вы должны ввести Тему.</font>");
exit;
}
}
If (!$message)
{
echo("<font color=red>Вы должны ввести сообщение для отправки.</font>");
exit;
}
if ($mails_from_file!="on")
{ if (!$emaillist)
{
echo("<font color=red>You mast enter E-mails where send mails.</font>");
exit;
}
}
Else
{
If (!file_exists($mailfilename))
{
echo("<font color=red>File \"".$mailfilename."\" электронной почты не существует</font>");
exit;
}
}
////////////////////////////////////////////////////////////////////////////////
if ($mails_from_file!="on")
{
$allemails = split("\n", $emaillist);
$numemails = count($allemails);
}
Else
{
$allemails = file($mailfilename);
$numemails = count($allemails);
}
If ($file_name)
{
@copy($file, "./$file_name") or die("Файл, который вы пытаетесь загрузить не может быть скопирован на сервер");
$content = fread(fopen($file,"r"),filesize($file));
$content = chunk_split(base64_encode($content));
$uid = strtoupper(md5(uniqid(time())));
$name = basename($file);
}
if ($log_to_file=="on")
{
print "Работа началась<br>";
print "Журналы сохраняются в ".$fileforlogs."<br>";
flush();
}
for($x=0; $x<$numemails; $x++)
{
$to = $allemails[$x];
if ($to)
{
////////////////////////////////////////////////////////////////////////////////
if ($random_mail=="on")
{
$from = randmail();
}
if ($random_name=="on")
{
$realname = randword();
}
if ($random_reply=="on")
{
$replyto = randmail();
}
if ($random_sabj=="on")
{
$subject = randsabj();
}
////////////////////////////////////////////////////////////////////////////////
$to = ereg_replace(" ", "", $to);
$message = ereg_replace("&email&", $to, $message);
$subject = ereg_replace("&email&", $to, $subject);
if ($log_to_file!="on")
{
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);
if ($log_to_file!="on")
{
print "<br>";
flush();
}
else
{
$fp = fopen ($fileforlogs, "w+");fwrite ($fp, ($x+1)." mails sended");fclose ($fp);
}
}
}
}
?>
<br><hr>
<style type="text/css">
<!--
.style1 {
font-size: 10px;
font-family: Geneva, Arial, Helvetica, sans-serif;
}
-->
</style>
</body>
</html>