Скрипт отправки почты

Discussion in 'PHP' started by _Sniper_, 11 Jan 2008.

Thread Status:
Not open for further replies.
  1. _Sniper_

    _Sniper_ Banned

    Joined:
    21 Jul 2007
    Messages:
    409
    Likes Received:
    147
    Reputations:
    -17
    Нужен рабочий скрипт анонимной отправки почты.
     
    1 person likes this.
  2. Piflit

    Piflit Banned

    Joined:
    11 Aug 2006
    Messages:
    1,249
    Likes Received:
    585
    Reputations:
    31
    mail(); (c)
     
    1 person likes this.
  3. _Sniper_

    _Sniper_ Banned

    Joined:
    21 Jul 2007
    Messages:
    409
    Likes Received:
    147
    Reputations:
    -17
    Did not understand. I do not understand strongly in php =)
     
  4. VDShark

    VDShark Elder - Старейшина

    Joined:
    1 Feb 2007
    Messages:
    260
    Likes Received:
    158
    Reputations:
    62
    http://ru2.php.net/mail
    Вот тебе и андерстенд... жми линк.
     
  5. _Sniper_

    _Sniper_ Banned

    Joined:
    21 Jul 2007
    Messages:
    409
    Likes Received:
    147
    Reputations:
    -17
    Немогу там зарегестрироваться =\
     
    1 person likes this.
  6. .:EnoT:.

    .:EnoT:. Сексуальное чудовище

    Joined:
    29 May 2007
    Messages:
    803
    Likes Received:
    559
    Reputations:
    50
    проще помоему некуда....писал сходу, не тестил, но должно работать:
    PHP:
    <?php
    if(isset($_POST['go']))
    {
       
    $to $_POST['to'];
       
    $ot $_POST['ot'];
       
    $subj $_POST['subj'];
       
    $mess $_POST['mess'];

       if(empty(
    $to) or empty($ot) or empty($subj) or   empty($mess))
       {
          echo
    "Заполните все поля";
       }
       else
       {
          
    mail($to$subj$mess"From: ".$ot);
       }        
    }
    else
    {
        
    ?> 
        <html><title>Анонимная отправка почты</title>
        <body>
        <form method="post">
        Кому:<br><input type="text" name="to" /><br />
        От:<br><input type="text" name="ot" /><br />
        Тема:<br><input type="text" name="subj" /><br />
        Текст:<br><textarea name="mess" /></textarea><br />
        <input type="submit" name="go" value="Отправить" /></form></body></html>
        
        <?php
        
    }
    ?>
    Многие ещё делают ведение логов когда и что отправлялось....
     
    #6 .:EnoT:., 11 Jan 2008
    Last edited: 11 Jan 2008
    1 person likes this.
  7. _Sniper_

    _Sniper_ Banned

    Joined:
    21 Jul 2007
    Messages:
    409
    Likes Received:
    147
    Reputations:
    -17
    Method Not Allowed
    The requested method POST is not allowed for the URL /1.html.


    ----------
    сча посмотрим

    -------------------
    Не работает..проверял на mail.ru :rolleyes:
     
    #7 _Sniper_, 11 Jan 2008
    Last edited: 11 Jan 2008
  8. .:EnoT:.

    .:EnoT:. Сексуальное чудовище

    Joined:
    29 May 2007
    Messages:
    803
    Likes Received:
    559
    Reputations:
    50
    я чёт не понял...ты что пытаешься выполнить скрипт в html? или в .htacess тада пропиши чтобы в файлах html исполнялся php код
     
  9. _Sniper_

    _Sniper_ Banned

    Joined:
    21 Jul 2007
    Messages:
    409
    Likes Received:
    147
    Reputations:
    -17
    Я проверял твой первый скрипт до редакт. поста. Сча проверил второй..php который. Не работает.

    Мне нужен чтоб работал на mail.ru
     
  10. .:EnoT:.

    .:EnoT:. Сексуальное чудовище

    Joined:
    29 May 2007
    Messages:
    803
    Likes Received:
    559
    Reputations:
    50
    только что проверил, у меня скрипт прекрасно работает
     
    1 person likes this.
  11. _Sniper_

    _Sniper_ Banned

    Joined:
    21 Jul 2007
    Messages:
    409
    Likes Received:
    147
    Reputations:
    -17
    Спасибо работает. Проблема была с хостингом.
     
  12. _Sniper_

    _Sniper_ Banned

    Joined:
    21 Jul 2007
    Messages:
    409
    Likes Received:
    147
    Reputations:
    -17
    Если прикрутиш поддержку аттача то вообще будет шик.
     
  13. banned

    banned Banned

    Joined:
    20 Nov 2006
    Messages:
    3,324
    Likes Received:
    1,194
    Reputations:
    252
    Не безопасно ставить на свой хостинг анонимную отправку писем для публики....
    Т.к. занесется айпи хостинга в спам лист и будете менять его :(
     
  14. _Sniper_

    _Sniper_ Banned

    Joined:
    21 Jul 2007
    Messages:
    409
    Likes Received:
    147
    Reputations:
    -17
    У меня много хостингов :D
     
  15. banned

    banned Banned

    Joined:
    20 Nov 2006
    Messages:
    3,324
    Likes Received:
    1,194
    Reputations:
    252
    attachement
    PHP:
    <?php
    function send_mail($to$body$subject$fromaddress$fromname$attachments=false)
    {
      
    $eol="\r\n";
      
    $mime_boundary=md5(time());

      
    # Common Headers
      
    $headers .= "From: ".$fromname."<".$fromaddress.">".$eol;
      
    $headers .= "Reply-To: ".$fromname."<".$fromaddress.">".$eol;
      
    $headers .= "Return-Path: ".$fromname."<".$fromaddress.">".$eol;    // these two to set reply address
      
    $headers .= "Message-ID: <".time()."-".$fromaddress.">".$eol;
      
    $headers .= "X-Mailer: PHP v".phpversion().$eol;          // These two to help avoid spam-filters

      # Boundry for marking the split & Multitype Headers
      
    $headers .= 'MIME-Version: 1.0'.$eol.$eol;
      
    $headers .= "Content-Type: multipart/mixed; boundary=\"".$mime_boundary."\"".$eol.$eol;

      
    # Open the first part of the mail
      
    $msg "--".$mime_boundary.$eol;
     
      
    $htmlalt_mime_boundary $mime_boundary."_htmlalt"//we must define a different MIME boundary for this section
      # Setup for text OR html -
      
    $msg .= "Content-Type: multipart/alternative; boundary=\"".$htmlalt_mime_boundary."\"".$eol.$eol;

      
    # Text Version
      
    $msg .= "--".$htmlalt_mime_boundary.$eol;
      
    $msg .= "Content-Type: text/plain; charset=iso-8859-1".$eol;
      
    $msg .= "Content-Transfer-Encoding: 8bit".$eol.$eol;
      
    $msg .= strip_tags(str_replace("<br>""\n"substr($body, (strpos($body"<body>")+6)))).$eol.$eol;

      
    # HTML Version
      
    $msg .= "--".$htmlalt_mime_boundary.$eol;
      
    $msg .= "Content-Type: text/html; charset=iso-8859-1".$eol;
      
    $msg .= "Content-Transfer-Encoding: 8bit".$eol.$eol;
      
    $msg .= $body.$eol.$eol;

      
    //close the html/plain text alternate portion
      
    $msg .= "--".$htmlalt_mime_boundary."--".$eol.$eol;

      if (
    $attachments !== false)
      {
        for(
    $i=0$i count($attachments); $i++)
        {
          if (
    is_file($attachments[$i]["file"]))
          {  
            
    # File for Attachment
            
    $file_name substr($attachments[$i]["file"], (strrpos($attachments[$i]["file"], "/")+1));
           
            
    $handle=fopen($attachments[$i]["file"], 'rb');
            
    $f_contents=fread($handlefilesize($attachments[$i]["file"]));
            
    $f_contents=chunk_split(base64_encode($f_contents));    //Encode The Data For Transition using base64_encode();
            
    $f_type=filetype($attachments[$i]["file"]);
            
    fclose($handle);
           
            
    # Attachment
            
    $msg .= "--".$mime_boundary.$eol;
            
    $msg .= "Content-Type: ".$attachments[$i]["content_type"]."; name=\"".$file_name."\"".$eol;  // sometimes i have to send MS Word, use 'msword' instead of 'pdf'
            
    $msg .= "Content-Transfer-Encoding: base64".$eol;
            
    $msg .= "Content-Description: ".$file_name.$eol;
            
    $msg .= "Content-Disposition: attachment; filename=\"".$file_name."\"".$eol.$eol// !! This line needs TWO end of lines !! IMPORTANT !!
            
    $msg .= $f_contents.$eol.$eol;
          }
        }
      }

      
    # Finished
      
    $msg .= "--".$mime_boundary."--".$eol.$eol;  // finish with two eol's for better security. see Injection.
     
      # SEND THE EMAIL
      
    ini_set(sendmail_from,$fromaddress);  // the INI lines are to force the From Address to be used !
      
    $mail_sent mail($to$subject$msg$headers);
     
      
    ini_restore(sendmail_from);
     
      return 
    $mail_sent;
    }
    ?>
     
    1 person likes this.
  16. _Sniper_

    _Sniper_ Banned

    Joined:
    21 Jul 2007
    Messages:
    409
    Likes Received:
    147
    Reputations:
    -17
    Отлично. Спасибо.
     
Thread Status:
Not open for further replies.