Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

 
Reply to this topicStart new topic
> PHP mailer., PHP mailer nie podaje danych z formularza w mailu.
kurde
post
Post #1





Grupa: Zarejestrowani
Postów: 16
Pomógł: 0
Dołączył: 8.09.2013

Ostrzeżenie: (0%)
-----


Witam. Mam problem z formularzem kontaktowym na http://www.biorel.pl

Nie przesyła do mnie na maila pola twój adres email. Przez co nie wiem komu na jaki adres trzeba odpisać na pytania, które coraz częściej wysyłają.


Co mam przesłać jakieś kody źródłowe czy coś. Proszę o poradę.

Ten post edytował kurde 1.03.2016, 20:57:31
Go to the top of the page
+Quote Post
Pyton_000
post
Post #2





Grupa: Zarejestrowani
Postów: 8 068
Pomógł: 1414
Dołączył: 26.10.2005

Ostrzeżenie: (0%)
-----


no przydałby się kod... formularza i obsługi...
Go to the top of the page
+Quote Post
kurde
post
Post #3





Grupa: Zarejestrowani
Postów: 16
Pomógł: 0
Dołączył: 8.09.2013

Ostrzeżenie: (0%)
-----


Kod Formularza:

Kod
<p>
Masz pytanie odnośnie naszych usług, wypełnij formularz, postaramy się niezwłocznie odpisać.
</p>


<!-- comment-form -->
               <div class="row">
                 <form method="post" action="sendEmail.php">
                   <div>
                     <div id="main">
                       <div class="span8">
                         <div class="comment1">
                           <p><input type="text" placeholder="twoje imie" name="name" id="name" class="commentfield" />
                           </p>
                         </div>
                           <div class="comment2">
                             <p> <input type="text" placeholder="twój adres e-mail" name="email" id="email" class="commentfield" />
                             </p>
                           </div>
                         <div class="comment3">
                           <p> <input type="text" placeholder="Temat" name="subject" id="subject" class="commentfield" />
                           </p>
                         </div>
                       </div>
                       <div class="span8 textarea">
                         <p><textarea name="comments" placeholder="Twoja wiadomość" id="comments" rows="12" cols="5" class="textarea"></textarea>
                         </p>
                         <div class="buttoncontact">
                           <p><input type="submit"  name="submit"  class="buttoncontact" id="submit" value="send message"/>
                           </p>
                         </div>
                       </div>
                       <ul class="span8" id="response"></ul>
                     </div>
                   </div>
                 </form>
               </div>
            
             <!-- comment-form-end -->


</div><!--leftabout end-->




Kod Obsługi:

Kod
<?php
    
    $name = trim($_POST['name']);
    $email = $_POST['email'];
        $subject = $_POST['subject'];
    $comments = $_POST['comments'];


        $site_owners_email = 'karol.manitus21@gmail.com'; // Replace this with your own hosting email address
    $site_owners_name = 'karol'; // replace with your name
    
    if (strlen($name) < 2) {
        $error['name'] = "Please enter your name";    
    }
    
    if (!preg_match('/^[a-z0-9&\'\.\-_\+]+@[a-z0-9\-]+\.([a-z0-9\-]+\.)*+[a-z]{2}/is', $email)) {
        $error['email'] = "Please enter a valid email address";    
    }
    
    if (strlen($comments) < 3) {
        $error['comments'] = "Please leave a comment.";
    }

        if (strlen($subject) < 2) {
        $error['subject'] = "Please enter subject.";
    }
    
    
    if (!$error) {
        
        require_once('phpMailer/PHPMailerAutoload.php');
        $mail = new PHPMailer();
        
        $mail->From = $email;
        $mail->FromName = $name;
        $mail->Subject = "$subject";
        $mail->AddAddress($site_owners_email, $site_owners_name);
        $mail->AddAddress('', '');
        $mail->IsHTML(true);  


$mail->Body = $comments;
$mail->email = $email;

        $mail->IsSMTP();
        $mail->Host = "smtp.gmail.com";
         $mail->Port = 587;
         $mail->SMTPSecure = "tls";
        
        $mail->SMTPAuth = true; // turn on SMTP authentication
        $mail->Username = "karol.manitus21@gmail.com"; // SMTP username
         $mail->Password = "hasła nie podam"; // SMTP password
        
        
$mail->SMTPDebug  = 0;
echo "<li class='success'> Dziękujemy, " . $name . ". Odpiszemy niezwłocznie jak tylko to będzie możliwe.</li>";
        
    } # end if no error
    else {

        $response = (isset($error['name'])) ? "<li class='error'>" . $error['name'] . "</li> \n" : null;
        $response .= (isset($error['email'])) ? "<li class='error'>" . $error['email'] . "</li> \n" : null;
                $response .= (isset($error['subject'])) ? "<li class='error'>" . $error['subject'] . "</li> \n" : null;
        $response .= (isset($error['comments'])) ? "<li class='error'>" . $error['comments'] . "</li>" : null;
        
        echo $response;
    } # end if there was an error sending


    if(!$mail->Send()) {
  echo "Mailer Error: " . $mail->ErrorInfo;
} else {
  echo "Message sent!";
}


?>
Go to the top of the page
+Quote Post
Pyton_000
post
Post #4





Grupa: Zarejestrowani
Postów: 8 068
Pomógł: 1414
Dołączył: 26.10.2005

Ostrzeżenie: (0%)
-----


  1. $mail->AddAddress('', '');
  2.  
  3. $mail->email = $email;

To CI jest nie potrzebne.

- W PHPMail masz metodę validateAddress()
- Dodaj jeszcze addReplyTo() z adresem nadawcy

Ustaw debug 1

Sprawdź źródło wysłanej wiadomości na swojej skrzynce i ew. pokaż ją.
Go to the top of the page
+Quote Post
kurde
post
Post #5





Grupa: Zarejestrowani
Postów: 16
Pomógł: 0
Dołączył: 8.09.2013

Ostrzeżenie: (0%)
-----


Kod
Return-Path: <karol.manitus21@gmail.com>
Received: from www.biorel.pl (s27.linuxpl.com. [136.243.44.221])
        by smtp.gmail.com with ESMTPSA id ka4sm2836574wjc.47.2016.02.24.04.42.24
        for <karol.manitus21@gmail.com>
        (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128);
        Wed, 24 Feb 2016 04:42:25 -0800 (PST)
From: SYLWIA <karol.manitus21@gmail.com>
X-Google-Original-From: SYLWIA <sjablonska@poczta.fm>
Date: Wed, 24 Feb 2016 13:42:23 +0100
To: karol <karol.manitus21@gmail.com>
Subject: godziny otwarcia
Message-ID: <d38a6bf256434d55b4a7e6257309212b@www.biorel.pl>
X-Priority: 3
X-Mailer: PHPMailer 5.2.10 (https://github.com/PHPMailer/PHPMailer/)
MIME-Version: 1.0
Content-Type: text/html; charset=iso-8859-1
Content-Transfer-Encoding: 8bit

Witam
Chciałabym wykupić groupon z masażami ale potrzebuje informację w jakie dni i w jakie godziny otwarty jest gabinet.


Widzę, że tutaj adres email się pojawia.

Wywaliłem te dwie linijki i ustawiłem smtpdebug na 1

Kod
Dziękujemy, Karol. Odpiszemy niezwłocznie jak tylko to będzie możliwe.
2016-03-02 09:58:37    CLIENT -> SERVER: EHLO www.biorel.pl 2016-03-02 09:58:37    CLIENT -> SERVER: STARTTLS 2016-03-02 09:58:37 CLIENT -> SERVER: EHLO www.biorel.pl 2016-03-02 09:58:37    CLIENT -> SERVER: AUTH LOGIN 2016-03-02 09:58:37    CLIENT -> SERVER: a2Fyb2wubWFuaXR1czIxQGdtYWlsLmNvbQ== 2016-03-02 09:58:37    CLIENT -> SERVER: SmFnb2RhNjk0Njc4NTU4 2016-03-02 09:58:37    CLIENT -> SERVER: MAIL FROM: 2016-03-02 09:58:37    CLIENT -> SERVER: RCPT TO: 2016-03-02 09:58:37    CLIENT -> SERVER: DATA 2016-03-02 09:58:37    CLIENT -> SERVER: Date: Wed, 2 Mar 2016 10:58:37 +0100 2016-03-02 09:58:37    CLIENT -> SERVER: To: karol 2016-03-02 09:58:37    CLIENT -> SERVER: From: Karol 2016-03-02 09:58:37    CLIENT -> SERVER: Subject: PAKIETY SPA 2016-03-02 09:58:37    CLIENT -> SERVER: Message-ID: <6369f0919509dda49ef8fbbe9bb1fa22@www.biorel.pl> 2016-03-02 09:58:37    CLIENT -> SERVER: X-Priority: 3 2016-03-02 09:58:37    CLIENT -> SERVER: X-Mailer: PHPMailer 5.2.10 (https://github.com/PHPMailer/PHPMailer/) 2016-03-02 09:58:37    CLIENT -> SERVER: MIME-Version: 1.0 2016-03-02 09:58:37    CLIENT -> SERVER: Content-Type: text/html; charset=iso-8859-1 2016-03-02 09:58:37    CLIENT -> SERVER: Content-Transfer-Encoding: 8bit 2016-03-02 09:58:37    CLIENT -> SERVER: 2016-03-02 09:58:37    CLIENT -> SERVER: Blablablablablablablabl 2016-03-02 09:58:37    CLIENT -> SERVER: 2016-03-02 09:58:37    CLIENT -> SERVER: . 2016-03-02 09:58:38    CLIENT -> SERVER: QUIT Message sent!


A tutaj kod który na stronie się pokazuje po ustawieniu smtpdebug na 1
Go to the top of the page
+Quote Post
Pyton_000
post
Post #6





Grupa: Zarejestrowani
Postów: 8 068
Pomógł: 1414
Dołączył: 26.10.2005

Ostrzeżenie: (0%)
-----


Czyli jest ok... Dodaj jeszcze sobie to "addReplyTo" z adresem nadawcy i będzie cacy.
Go to the top of the page
+Quote Post
kurde
post
Post #7





Grupa: Zarejestrowani
Postów: 16
Pomógł: 0
Dołączył: 8.09.2013

Ostrzeżenie: (0%)
-----


Okej jestem trochę zielony, co w tym nawiasie mam dać (IMG:style_emoticons/default/smile.gif)

Tzn. Jeżeli to dodam, chodzi o to, żebym w mailu widział adres podany w tym polu twój adres email, żebym nie musiał patrzyć na oryginał wiadomości, inaczej na źródło.

addreplyto to załatwi ?

Ten post edytował kurde 2.03.2016, 12:25:55
Go to the top of the page
+Quote Post

Reply to this topicStart new topic
2 Użytkowników czyta ten temat (2 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Aktualny czas: 25.08.2025 - 12:37