Autor Zpráva
makromat
Profil
Zdravim vsetkych,

Nefunguje mi automatický dakovací mail z formuláru ktorý by sa mal odosielať na adresu ktorú zadá zákaznik.

Takzě takto vyzerá php mail


$msg = "Form Contents: \n\n";
          foreach($this->fields as $key => $field)
                $msg .= "$key :  $field \n";

          // $to = 'email@adresa.sk';
          
          $subject = 'Form Submission';
          $from = 'info@web2me.sk';

          mail($to, $subject, $msg, "From: $from\r\nReply-To: $from\r\nReturn-Path: $from\r\n");
          
          $to = $this->fields['email_fld'];

email_fld je meno inputu kde sa zadáva mail....

Ak odzatvorkujem

// $to = 'email@adresa.sk';

a zazatvorkujem

$to = $this->fields['email_fld'];

mail príde .....

Vopred dakujem za rady ...
tiso
Profil
riadok 12 musí byť pred riadkom 10
makromat
Profil
Ukaze ze ze je sucsess ale neodosle mail .....

$msg = "Form Contents: \n\n";
         foreach($this->fields as $key => $field)
               $msg .= "$key :  $field \n";
               
         $to = $this->fields['email_fld'];
         //$to = 'default@mail.com';
         
         $subject = 'Form Submission';
         $from = 'info@mail.sk';

         if($_POST['select'] == "field3-1"){
         mail($to, $subject, $msg, "From: $from\r\nReply-To: $from\r\nReturn-Path: $from\r\n");
         }

Neviem kde robim chybu ci musim dat value z formu alebo idecko.....

Takto mi to funguje aj mi pride mail :

$msg = "Form Contents: \n\n";
         foreach($this->fields as $key => $field)
               $msg .= "$key :  $field \n";
               
         $to = $this->fields['email_fld'];
         //$to = 'default@mail.com';
         
         $subject = 'Form Submission';
         $from = 'info@mail.sk';

         mail($to, $subject, $msg, "From: $from\r\nReply-To: $from\r\nReturn-Path: $from\r\n");
         

A chcel by som spravit nieco taketo :

$msg = "Form Contents: \n\n";
         foreach($this->fields as $key => $field)
               $msg .= "$key :  $field \n";
               
         $to = $this->fields['email_fld'];
         //$to = 'default@mail.com';
         
         $subject = 'Form Submission';
         $from = 'info@mail.sk';

         if($_POST['select'] == "field3-1"){
         mail($to, $subject, $msg, "From: $from\r\nReply-To: $from\r\nReturn-Path: $from\r\n");
         }
         elseif($_POST['select'] == "field3-2"){
         mail($to, $subject, $msg, "From: $from\r\nReply-To: $from\r\nReturn-Path: $from\r\n");
         }
         elseif($_POST['select'] == "field3-3"){
         mail($to, $subject, $msg, "From: $from\r\nReply-To: $from\r\nReturn-Path: $from\r\n");
         }
         


Mail mi nechce prist prosim neviete kde mam chybu ?
Ďakujem


tiso:
Ďakujem pomohlo to ....

Nevedel by si poradiť ako spraviť že mi bude odosielať správu na základe toho ktorú polozku zvolí vo formuláre zo select ?
tiso
Profil
makromat: „Nevedel by si poradiť...

Vedel, ukáž ten formulár a čím sa líšia tie správy, pretože v tvojej ukážke sa snažíš poslať stále tú istú.
makromat
Profil
makromat:


Zdravim takze mam to uz takto spravene :


$msg = "Form Contents: \n\n";
         foreach($this->fields as $key => $field)
         
               $msg1 .= file_get_contents("odpoved_1.html");
               
               $msg2 .= file_get_contents("odpoved_2.html");
               
               $msg3 .= file_get_contents("odpoved_3.html");
               
               $msg4 .= file_get_contents("odpoved_4.html");
               
               $msg5 .= file_get_contents("odpoved_5.html");
               
               $msg6 .= file_get_contents("odpoved_6.html");
               
               
         $to = $this->fields['email_fld'];
         $subject = 'Nezávezná objednávka';
         $from = 'moj@mail.sk';
         

         
         if($_POST['ponuka_fld'] == "option_1"){
         mail($to, $subject, $msg1, "From: $from\r\nReply-To: $from\r\nReturn-Path: $from\r\n");
         }
         elseif($_POST['ponuka_fld'] == "option_2"){
         mail($to, $subject, $msg2, "From: $from\r\nReply-To: $from\r\nReturn-Path: $from\r\n");
         }
         elseif($_POST['ponuka_fld'] == "option_3"){
         mail($to, $subject, $msg3, "From: $from\r\nReply-To: $from\r\nReturn-Path: $from\r\n");
         }
         elseif($_POST['ponuka_fld'] == "option_4"){
         mail($to, $subject, $msg4, "From: $from\r\nReply-To: $from\r\nReturn-Path: $from\r\n");
         }
         elseif($_POST['ponuka_fld'] == "option_5"){
         mail($to, $subject, $msg5, "From: $from\r\nReply-To: $from\r\nReturn-Path: $from\r\n");
         }
         elseif($_POST['ponuka_fld'] == "option_6"){
         mail($to, $subject, $msg6, "From: $from\r\nReply-To: $from\r\nReturn-Path: $from\r\n");
         }


Lenze ked napisem do tych html suborov - sprav html tak mi zobrazi aj tagy .....
Docital som sa ze by som tam mal pridat nieco takehoto :

$headers .= "Content-Type: text/plain; charset = \"UTF-8\";\n";
$headers .= "Content-Transfer-Encoding: 8bit\n";
$headers .= "\n";


Ale neviem to tam stale zladit aby mi to posielalo mail pretoze mi chodia len vzdy maily z websupportu o chybe ..

Neviete poradit prosim ?
peta
Profil
Timto by ses zbavil elegantne toho balastu if-else
$id = str_replace('option_','',$_POST['ponuka_fld']) * 1;
if (in_array($id,array(1,2,3,4,5,6)))
{
  $msg = ${'msg'.$id}; // nebo vybrat z pole $msg[$id] a nebo primo $msg .= file_get_contents("odpoved_".$id.".html");
  $headers = "From: $from\r\nReply-To: $from\r\nReturn-Path: $from\r\n";
  mail($to, $subject, $msg, $headers);
}

Chces se zbavit tagu? Pak by se ti mohli hodit tyto funkce
http://cz2.php.net/htmlspecialchars - prevest tagy z textu na zobrazitelny text pro html
http://cz2.php.net/strip_tags - odstranit tagy
http://cz2.php.net/nl2br - prevest \n na <br>
http://cz2.php.net/str_replace - prevest <br> na \n
http://cz2.php.net/mail - informace k funkci mail, v prikladech zmena kodovani; Example #4 Sending HTML email - odeslani mailu jako html kod ; odelsani mailu s prilohou 7
Anda

Vaše odpověď


Prosím používejte diakritiku a interpunkci.

Ochrana proti spamu. Napište prosím číslo dvě-sta čtyřicet-sedm: