NuSphere Forums Forum Index
NuSphere Forums
Reply to topic
mailserver


Joined: 20 Jun 2007
Posts: 3
Reply with quote
Just downloaded and installed PhpDock, and managed to run my first php code. In the code I use the mail function.
When I run it, I get the following error:
Warning: mail() [function.mail]: Failed to connect to mailserver at "localhost" port 25, verify your "SMTP" and "smtp_port" setting in php.ini or use ini_set() in C:\Program Files\phpdock\web\index.php on line 67

How can I modify the php.ini to get this mail function working Question

advTHANKSance,

Simon
View user's profileFind all posts by simonSend private message
Site Admin

Joined: 13 Jul 2003
Posts: 8334
Reply with quote
please check with php manual on how to invoke mail() function.
Obviously you do not have mail (SMTP) server on your machine and that's why the function has failed.

_________________
The PHP IDE team
View user's profileFind all posts by dmitriSend private messageVisit poster's website


Joined: 20 Jun 2007
Posts: 3
Reply with quote
In my code I have the mail function already defined:

Code:
 $m = mail($email, $subject, $inhoud, "FROM:".$from);


Regarding the SMTP server on my machine: I can send and receive mail now with Outlook, does that mean that I have a SMTP server?
Even if I don't have an SMTP server, I don't have a PHP server either. I thougth that PhpDock would take care of that, hence my question how to add that in the php.ini.......
View user's profileFind all posts by simonSend private message
Site Admin

Joined: 13 Jul 2003
Posts: 8334
Reply with quote
with outlook, you have to create an account and specify SMTP and POP3 or IMAP servers. Right?
Use the same SMTP as in outlook.
See mail() settings in php.ini http://www.php.net/mail

_________________
The PHP IDE team
View user's profileFind all posts by dmitriSend private messageVisit poster's website


Joined: 20 Jun 2007
Posts: 3
Reply with quote
dmitri,
I don't understand. I admit that i'm a noob in php Embarassed Therefore more questions:
- how do I create that SMTP server in phpdock.ini Question Can you write me down what I need to add?
- the code itself, which I test with phpdock, doesn't need any additions I guess?
Code:
<?php

//////////////////////////////////////////
// gegevens:
//////////////////////////////////////////

//dit is de reekst van namen van de spelers waaruit ze kunnen kiezen
$namen = array();
$namen[] = "David Beckers";
$namen[] = "Johan Beckers";
$namen[] = "Alain Blommaert";
$namen[] = "Stijn Couder";
$namen[] = "Dirk Craps";
$namen[] = "Kris De Quint";
$namen[] = "Lieven Desaveur";
$namen[] = "Dany Devogelaer";
//.enzovoort....

//dit is een reeks van data waaruit ze kunnen kiezen (opmaak van datum mag je zelf kiezen!)
$data = array();
$data[] = "1 September";
$data[] = "8 September";
$data[] = "15 September";
$data[] = "21 September";
$data[] = "28 September";
//.enzovoort....

//mailgegevens:
$email = "simon.smidt@telenet.be";
$subject = "Spelergegevens!";
$from = "VOK website <simon.smidt@telenet.be>";

//inhoud van de mail \n = een enter, ::SPELER:: is de spelernaam en ::DATA:: zijn de data dat de speler kan!
$inhoud = "Hallo,\n
De speler '::SPELER::' kan de volgende data komen: \n
::DATA::";



//////////////////////////////////////////
// Vanaf hier code:
//////////////////////////////////////////

if($_SERVER['REQUEST_METHOD'] == "POST") {
   //gegevens doorsturen!
   //testen op naam
   if(isset($_POST['speler']) && $_POST['speler'] != "0") {
   
      //testen op data
      if(isset($_POST['fdata'])) {
         $str = implode("::", $_POST['fdata']);
         $arr = explode("::", $str);
         $hoeveel = count($arr);
         // nog een test op datum
         if($hoeveel >= 1) {
            //gegevens klaar maken om door te mailen:
            $mdata = "";
            foreach($arr as $x) {
               $mdata .= $x."\n";
            }
           
            //de gegevens in de inhoud invullen:
            $inhoud = str_replace("::SPELER::", $_POST['speler'], $inhoud);
            $inhoud = str_replace("::DATA::", $mdata, $inhoud);
           
            //de mail zelf versturen:
            $m = mail($email, $subject, $inhoud, "FROM:".$from);
            //testen of de mail verstuurd werd:
            if($m) {
               $title = "Data verstuurd!";
               $body = "<p><strong>Volgende mail werd verstuurd:</strong></p><p>".nl2br($inhoud)."</p>";
            } else {
               $title = "Foutje!";
               $body = "<p><font color=red>De mail kon door een interne fout niet verstuurd worden, gelieve <a href=\"javascript:history.back(-1)\">opnieuw te proberen</a> of stuur een mail naar <a href=mailto:simon.smidt@telenet.be?Subject=Datum_probleem_op_website>Simon</a> met je datums !</font></p>";               
            }
         
         } else {
            $title = "Foutje!";
            $body = "Je hebt geen enkele datum ingevuld ! Ga <a href=\"javascript:history.back(-1)\">terug</a>.";                 
         }
      } else {
         $title = "Foutje!";
         $body = "Je hebt geen enkele datum ingevuld ! Ga <a href=\"javascript:history.back(-1)\">terug</a>.";     
      }
   } else {
      $title = "Foutje !";
      $body = "Je hebt geen naam gekozen ! Ga <a href=\"javascript:history.back(-1)\">terug</a>.";
   }
   
   
} else {
   //formulier aanmaken
   $title = 'Wanneer kan jij ?';
   $body = '<form action="'.$_SERVER['PHP_SELF'].'" method="post"><fieldset>';
   
   //naam selecteren
   $body .= '<p><strong>Naam:</strong> <select name="speler"><option value="0">--Kies je naam--</option>';
   foreach($namen as $speler) {
      $body .= '<option value="'.$speler.'">'.$speler.'</option>';
   }
   $body .= '</select></p>';
   
   //mogelijke datums neerprinten
   $body .= '<p><strong>Kies de datums waarop jij kan spelen</strong><br />';
   $i = 0;
   foreach($data as $datum) {
      $body .= '<input type="checkbox" name="fdata['.$i.']" value="'.$datum.'" />'.$datum.'<br />';
      $i++;
   }
   $body .= '</p>';
 
   $body .= '<input type="submit" value="Verzend je datums!" /></fieldset></form>';
   

}


?>

View user's profileFind all posts by simonSend private message
Site Admin

Joined: 13 Jul 2003
Posts: 8334
Reply with quote
Quote:
I don't understand. I admit that i'm a noob in php

php or phpdock has nothing to do with this.
SMTP is a server that runs and accepts your mails. For example, if you have a gmail email account, say myaccount@gmail.com, you'll have to specify smtp.gmail.com as an SMTP server accepting your emails. Please consult with your email provider.

_________________
The PHP IDE team
View user's profileFind all posts by dmitriSend private messageVisit poster's website
mailserver
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
All times are GMT - 5 Hours  
Page 1 of 1  

  
  
 Reply to topic