Ankündigung

Einklappen
Keine Ankündigung bisher.

Problem beim Mail-Versand mit dem SMTP-Skript von M. Lemos

Einklappen

Neue Werbung 2019

Einklappen
X
  • Filter
  • Zeit
  • Anzeigen
Alles löschen
neue Beiträge

  • Problem beim Mail-Versand mit dem SMTP-Skript von M. Lemos

    Hallo zusammen,

    ich verwende für den Versand von Mails über einen GMX-Account die Klasse smtp von Manuel Lemos (http://www.phpclasses.org/browse/package/14.html).

    Wenn ich das mitgelieferte Test-Script verwende funktioniert der Versand. Wenn ich hingegen meine eigene Funktion verwende, bekomme ich den folgenden Fehler: could not determine the SMTP to connect

    Für beide Scripte verwende ich die gleichen Daten.

    Test-Script:
    Code:
    <?php
    	  $smtp = new smtp_class;
    
    		$smtp->host_name=$host_name;
    	  	$smtp->localhost=$localhost;
    		$smtp->pop3_auth_host=$pop3_auth_host;
    		$smtp->user=$mail_user;
    		$smtp->realm=$realm;
    		$smtp->password=$mail_password;
    
    		
    	  
    		$from=$mail_from;
    	  	$to=$mailaddress;
    		$inhalt = $mailtext;
    	  
    	  $smtp->direct_delivery=0;     /* Set to 1 to deliver directly to the recepient SMTP server */
    		$smtp->timeout=10;            /* Set to the number of seconds wait for a successful connection to the SMTP server */
    		$smtp->data_timeout=0;        /* Set to the number seconds wait for sending or retrieving data from the SMTP server. Set to 0 to use the same defined in the timeout variable */
    		$smtp->debug=0;               /* Set to 1 to output the communication with the SMTP server */
    		$smtp->html_debug=1;          /* Set to 1 to format the debug output as HTML */	  
    	
    	if(		$smtp->SendMessage($from,
    			array($to),
    			array(
    				"From: $from",
    				"To: $to",
    				"Subject: ".$betreff,
    				"Date: ".strftime("%a, %d %b %Y %H:%M:%S %Z")
    			),
    			$inhalt))
    		echo "Message sent to $to OK.\n";
    	else
    		echo "Cound not send the message to $to.\nError: ".$smtp->error."\n"
    ?>

    Eigene Funktion:
    Code:
    function sendEMail($empfaenger, $betreff, $mailtext)
    	{		
    	  $smtp = new smtp_class;
    	  //$smtp->host_name=getenv("HOSTNAME");
    
    		$smtp->host_name=$host_name;
    	  	$smtp->localhost=$localhost;
    		$smtp->pop3_auth_host=$pop3_auth_host;
    		$smtp->user=$mail_user;
    		$smtp->realm=$realm;
    		$smtp->password=$mail_password;
    			  
    		$from=$mail_from;
    	  	$to=$mailaddress;
    //	    $to = $empfaenger;
    		$inhalt = $mailtext;
    	  
    	  $smtp->direct_delivery=0;     /* Set to 1 to deliver directly to the recepient SMTP server */
    		$smtp->timeout=10;            /* Set to the number of seconds wait for a successful connection to the SMTP server */
    		$smtp->data_timeout=0;        /* Set to the number seconds wait for sending or retrieving data from the SMTP server. Set to 0 to use the same defined in the timeout variable */
    		$smtp->debug=0;               /* Set to 1 to output the communication with the SMTP server */
    		$smtp->html_debug=1;          /* Set to 1 to format the debug output as HTML */	  
    	
    		if($smtp->SendMessage($from,
    			array($to),
    			array(
    				"From: $from",
    				"To: $to",
    				"Subject: ".$betreff,
    				"Date: ".strftime("%a, %d %b %Y %H:%M:%S %Z")
    			),
    			$inhalt))
    			{
    				echo "Die Nachricht wurde erfolgreich an '$to' geschickt.\n";
    			}
    			else
    			{
    				echo "Die Nachricht konnte nicht an '$to' gesendet werden.\nFehler: ".$smtp->error."\n";
    			}
    	}
    Hat jemand eine Idee, warum es beim Test geht und bei meiner Funktion nicht?

    Gruß,
    Ole

  • #2
    Wo werden die Variablen $host_name etc. definiert?

    Kommentar


    • #3
      In der Datei ConfigDaten.php, die in der zentralen Datei index.php included wird:

      Code:
      	include_once("ConfigDaten.php");  // Hier stehen die Variablen
      	include_once("php/util/smtp.php");  // SMTP-Programm
      	include_once("php/util/Tools.php");  // Hier ist meine Funktion
      	include_once("php/_thirdparty/test_smtp.php");  // SMTP-Test
      Mir kam auch gerade der Gedanke, dass die Variablen wohl nicht gesetzt sind. Mir ist nur nicht klar, warum sie im test_smtp.php Script gesetzt sind und im Tools.php nicht.

      Wer weiß weiter?

      Kommentar


      • #4
        Dachte ich es mir doch:

        http://de2.php.net/manual/en/languag...bles.scope.php

        Kommentar


        • #5
          Vielen Dank!

          Ich lebe halt doch irgendwie in der Java-Welt

          Kommentar


          • #6
            Bitte bei PHP-Quellcode [PHP]-Tags benutzen:
            Code:
                
                
                
            
            
            PHP-Code:
             /*  Hier Quellcode posten, natürlich ohne [ code ] :-)  */ 

            Kommentar

            Lädt...
            X