Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [PHP]Formularz kontaktowy - email nie dochodzi.
mateŁusz
post
Post #1





Grupa: Zarejestrowani
Postów: 102
Pomógł: 0
Dołączył: 21.08.2012

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


A więc mam taki formularz kontaktowy:

kontakt.php
  1. <html>
  2. <head>
  3. </head>
  4. <body>
  5.  
  6. <form action="wyslij.php" method="post">
  7. Nick:
  8. <input type="text" name="nick" /><br />
  9. E-mail:
  10. <input type="text" name="mail" /><br />
  11. Tresc:<br />
  12. <textarea name="tresc" /></textarea><br />
  13. <input type="submit" value="Wyślij">
  14. </form>
  15. </body>
  16. </html>



wyslij.php

  1. <?
  2. $mail="mojemail@o2.pl";
  3. if($_POST['tresc'] && $_POST['mail'] && $_POST['nick']){
  4. $tresc = 'Tresc: '.$_POST['tresc'].' \nWysłał: '.$_POST['nick'].' email: '.$_POST['mail'];
  5. if (mail($mail, "Tytul wiadomosci", $tresc)){
  6. echo 'Mail został wysłany <a href="link">Powrót</a>';
  7. }else{
  8. echo 'Mail nie został wysłany <a href="link">Powrót</a>';
  9. }
  10. }else{
  11. echo'Proszę wypełnić wszystkie pola';
  12. }
  13. ?>


Po wypełnieniu formularza i naciśnięciu 'Wyślij' pisze, że mail został wysłany. Sprawa wygląda tak, iż te emaile nie dochodzą na wskazany adres email.
Patrzyłem na dwóch emailach 4 godziny temu i na żaden nie doszedł..
A więc. Co jest źle? Jak to naprawić?

Ten post edytował mateŁusz 4.11.2012, 00:01:44
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi
Aevon
post
Post #2





Grupa: Zarejestrowani
Postów: 1
Pomógł: 0
Dołączył: 4.11.2012

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


Witam, nie wiem czy powinienem zakładac nowy temat, czy raczej się dopisać skoro mam podobny problem.

Sprawa wygląda tak, ( wiem wiem zgroza (IMG:style_emoticons/default/tongue.gif) ) ściągnąłem template strony internetowej i chciałem ją przerobić, jako, że moje kodowanie i rozumienie zasad działania php jest zerowe (IMG:style_emoticons/default/smile.gif) z html i css metodą prób i błędów sobie poradzę, trochę namieszam, ale dam rade (IMG:style_emoticons/default/tongue.gif)

Otóż, wszystko fajnie, szablon mi się podoba itd, można go w pełni edytować, ale nie mam zielonego pojęcia jak ustawić "Contact Form" żeby działał, od razu mówie, że trzeba mi tłłumaczyć dość łopatologicznie (IMG:style_emoticons/default/smile.gif) maile nie dochodzą, nawet nie wiem czy powinny (IMG:style_emoticons/default/biggrin.gif)

Z góry dziękuję za pomoc (IMG:style_emoticons/default/smile.gif)

CODE
<?php
$owner_email = $_POST["owner_email"];
$headers = 'From:' . $_POST["email"];
$subject = 'A message from your site visitor ' . $_POST["name"];
$messageBody = "";

if($_POST['name']!='nope'){
$messageBody .= '<p>Visitor: ' . $_POST["name"] . '</p>' . "\n";
$messageBody .= '<br>' . "\n";
}
if($_POST['email']!='nope'){
$messageBody .= '<p>Email Address: ' . $_POST['email'] . '</p>' . "\n";
$messageBody .= '<br>' . "\n";
}else{
$headers = '';
}
if($_POST['state']!='nope'){
$messageBody .= '<p>State: ' . $_POST['state'] . '</p>' . "\n";
$messageBody .= '<br>' . "\n";
}
if($_POST['phone']!='nope'){
$messageBody .= '<p>Phone Number: ' . $_POST['phone'] . '</p>' . "\n";
$messageBody .= '<br>' . "\n";
}
if($_POST['fax']!='nope'){
$messageBody .= '<p>Fax Number: ' . $_POST['fax'] . '</p>' . "\n";
$messageBody .= '<br>' . "\n";
}
if($_POST['message']!='nope'){
$messageBody .= '<p>Message: ' . $_POST['message'] . '</p>' . "\n";
}

if($_POST["stripHTML"] == 'true'){
$messageBody = strip_tags($messageBody);
}

try{
if(!mail($owner_email, $subject, $messageBody, $headers)){
throw new Exception('mail failed');
}else{
echo 'mail sent';
}
}catch(Exception $e){
echo $e->getMessage() ."\n";
}
?>


mam jeszcze plik ashx (IMG:style_emoticons/default/smile.gif)

CODE
<%@ WebHandler Language="C#" Class="Handler" Debug="true" %>

using System;
using System.Web;
using System.Net.Mail;
using System.Text.RegularExpressions;

public class Handler : IHttpHandler {
public void ProcessRequest (HttpContext context) {
SmtpClient mailClient = new SmtpClient(context.Request.Form.Get("smtpMailServer"));
string owner_email = context.Request.Form.Get("owner_email");
string subject = "A message from your site visitor " + context.Request.Form.Get("name");
string email = context.Request.Form.Get("email");
string messageBody = "";

messageBody += "<p>Visitor: " + context.Request.Form.Get("name") + "</p>\n";
messageBody += "<br>\n";
messageBody += "<p>Email Address: " + context.Request.Form.Get("email") + "</p>\n";
messageBody += "<br>\n";
messageBody += "<p>Phone Number: " + context.Request.Form.Get("phone") + "</p>\n";
messageBody += "<br>\n";
messageBody += "<p>Message: " + context.Request.Form.Get("message") + "</p>\n";


MailMessage message = new MailMessage();

try{
message.From = new MailAddress(email.ToString());
}catch (FormatException e) {
context.Response.Write(e.Message);
}

message.To.Add(owner_email);
message.Subject = subject;
if(context.Request.Form.Get("stripHTML") == "true"){
message.IsBodyHtml = false;
messageBody = Regex.Replace(messageBody, "<.*?>", string.Empty);
}else{
message.IsBodyHtml = true;
}
message.Body = messageBody;

try{
mailClient.Send(message);
}catch (SmtpException e) {
context.Response.Write("mail failed");
}
context.Response.Write("mail sent");
}

public bool IsReusable {
get {
return false;
}
}
}


no i miejsce w index.html gdzie ( tak myślę ) powinno się znajdować jakiekolwiek odniesienie (IMG:style_emoticons/default/wink.gif)

CODE
<form action="MailHandler.php" id="ContactForm">
<div class="success"> Contact form submitted!&nbsp;We will be in touch soon.</div>
<fieldset class="left">
<div class="block">
<label class="name padRight3">
<span class="title1">Name:</span>
<span class="bg"><input type="text" value="" class="input"></span>
<span class="error">*To nie jest poprawne imię.</span> <span class="empty">*This field is required.</span> </label>
<label class="email">
<span class="title1">Email:</span>
<span class="bg"><input type="email" value="" class="input"></span>
<span class="error">*To nie jest poprawny e-mail.</span> <span class="empty">*This field is required.</span></label>

<label class="phone">
<span class="title1">Phone:</span>
<span class="bg"><input type="tel" value="" class="input"></span>
<span class="error">*To nie jest poprawny telefon.</span> <span class="empty">*This field is required.</span> </label>
</div>

<div class="block">
<label class="message">
<span class="title1">Message:</span>
<span class="bg"><textarea rows="1" cols="2"></textarea></span>
<span class="error">Hmm, I guess your message is too short.</span> <span class="empty">*This field is required.</span> </label>
</div>
<div class="formButtons">
<div class="formBtn">
<a href="#" data-type="submit" class="moreButton">Send</a>
</div>
<div class="formBtn">
<a href="#" data-type="reset" class="moreButton">Clear</a>
</div>
</div>
</fieldset>
</form>
Go to the top of the page
+Quote Post

Posty w temacie
- mateŁusz   [PHP]Formularz kontaktowy - email nie dochodzi.   3.11.2012, 23:57:53
- - jaslanin   sprawdziłeś czy nie trafiły do folderu spam?   4.11.2012, 09:07:03
- - mkamin   [PHP] pobierz, plaintext <? $mail="m...   4.11.2012, 10:22:55
- - mateŁusz   Cytat(jaslanin @ 4.11.2012, 09:07:03 ...   4.11.2012, 10:25:20
- - mkamin   [PHP] pobierz, plaintext <input type="text...   4.11.2012, 11:16:51
- - mateŁusz   Teraz to w ogóle nic nie działa. Email przychodzi,...   4.11.2012, 11:53:23
- - viking   To że maile nie dochodzą niekoniecznie musi być wi...   4.11.2012, 11:56:28
- - mateŁusz   Już dochodzą, ale puste : D   4.11.2012, 12:03:34
- - mkamin   [PHP] pobierz, plaintext if (!empty($_POST...   4.11.2012, 12:28:50
- - mateŁusz   Cały czas zwraca CytatPodaj prawidłowy adres emai...   4.11.2012, 12:42:47
- - viking   [a-z]{2} Przyjmuje tylko adresy .xx, dwuznakowe do...   4.11.2012, 12:52:24
- - mkamin   Z formularza nie usunąłeś mam nadzieję pola mail? ...   4.11.2012, 12:56:05
- - elvis385   Witam serdecznie! Nie zakładam nowego tematu b...   4.11.2012, 13:06:47
- - mkamin   Spróbuj tak: [PHP] pobierz, plaintext  $wiado...   4.11.2012, 13:21:36
- - mateŁusz   /\Takie wypełnienie jest prawidłowe? [PHP]...   4.11.2012, 13:29:48
- - mkamin   Tak. Sprawdź czy przechodzi mail bez sprawdzania p...   4.11.2012, 13:40:32
- - mateŁusz   CytatDziękujemy za przeslanie wiadomości Powrót do...   4.11.2012, 13:49:50
|- - mkamin   Cytat(mateŁusz @ 4.11.2012, 13:49:50 ...   4.11.2012, 13:53:56
- - mateŁusz   Bóg Ci w dzieciach wynagrodzi Czy działa tak jak ...   4.11.2012, 13:58:09
- - mkamin   i jeszcze został [PHP] pobierz, plaintext $heade...   4.11.2012, 14:02:00
- - mateŁusz   Wiem, wiem.. poprawiłem to od razu Jakbym chciał ...   4.11.2012, 14:06:45
- - mkamin   Dodajesz do formularza pole [HTML] pobierz, plaint...   4.11.2012, 14:15:41
- - mateŁusz   Rozumiem. Dziękuję.. "pomógł" porozdawan...   4.11.2012, 14:19:27
- - Aevon   RE: [PHP]Formularz kontaktowy - email nie dochodzi.   4.11.2012, 14:50:11
- - mateŁusz   3,5h, a emaila nadal w skrzynce nie widać..   4.11.2012, 17:22:49
- - viking   Bo widzisz. Wiesz chociaż na przyszłość że błędów ...   4.11.2012, 17:56:51
- - elvis385   Cytat(mkamin @ 4.11.2012, 13:21:36 ) ...   4.11.2012, 18:03:54
- - Exemu   Witam! Nie zakładam nowego tematu, mam taki sa...   4.11.2012, 18:03:59


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: 14.10.2025 - 14:50