Zum Inhalt springen

cwt community - emailversand bei neuer nachricht

Erstellt am 28. September 2007 · 21 Antworten · letzte Antwort am 4. März 2008 · Seite 1 von 2

Tags: E-Mail-Versand, Frage

Dario ·

Hallo Simon,

hier kommt der Code

function getViewMessagesNewResult($uid, $recipient_uid)
    {
        // Init Vars
        $action = "getviewmessagesnewresult";
        $content = "";
        $cObj = $this -> cObj; //Holds a typo content object
        $templateCode = null; //Hold the template source code.
        $conf["subpartMarker"] = "VIEW_MESSAGES_NEW_RESULT"; //Holds a subpart marker.
        $subSub_1 = "ADDITIONAL";

        // Get the html source between subpart markers from template file
        $templateCode = $cObj -> getSubpart($this -> orig_templateCode, "###" . $conf["subpartMarker"] . "###");

		$empfaenger = $_GET["recipient_uid"];
        $abfrage = "SELECT email FROM fe_users WHERE uid = ".$empfaenger;
        $ergebnis = mysql_query($abfrage);
        while($row = mysql_fetch_object($ergebnis))
            {
                  $emailempfaenger = $row->email;
                }
           mail($emailempfaenger, "Sie haben eine neue Nachricht erhalten", "Also auf und lesen!");
		
        /*
        * HANDLE ADDITIONAL
        */
        // Init subpart content
        $subpartContent = null;
        // Get link to messages
        $linkToMessages = $this -> pi_getPageLink($GLOBALS['TSFE']->id, "", array("action" => "getviewmessages", "uid" => $uid));
sobi555 ·

Probier mal, den einzfügenden Code ganz ans Ende der Funktion zu stellen. Also "$empfaenger = $_GET["recipient_uid"];" kommt nach "$content = $templateCode;"
Und Erfolg gehabt? (Wenn nicht, poste mal die ganze Funktion und markier mit dir "Felerzeile")
LG

sobi555 ·

Dann füge mal vor die Zeile Mail(...); die Zeile "echo $row->email;" ein. Wenn er dort die eMailadressen auflistet, dann ersetzte mal die Zeile durch "echo $emailempfaenger;" - was passiert dann?

Dario ·

NICHTS,

keine Auflistung, kein Fehlermeldung, keine E-Mail

#angry# #angry# #angry# #angry#

Grüße

Dario

sobi555 ·

Okay... und mit

echo $empfaenger;

? (da müsste er dir ganz oben rechts eine Zahl hinschreiben, drunter eine Fehlermeldung)

Dario ·

Neee,

macht er nicht.

"Die Nachricht wurde gesendet.."

Keine weitere Meldungen oder Fehler

sobi555 ·

Du hast noch nicht viel mit PHP gemacht, oder? Mir fällt gerade auf (und ein) dass du wahrscheinlich das "return" vor der mail-funktion hast? (ansonsten müssen wir das mal per Mail weiterführen, da ich mir am leichtesten tu, wenn ich die "Dinge" vor mir habe und ggf. selber testen kann...

LG - Simon
Anbei noch mal die Funktion:

    function getViewMessagesNewResult($uid, $recipient_uid)
    {
        // Init Vars
        $action = "getviewmessagesnewresult";
        $content = "";
        $cObj = $this -> cObj; //Holds a typo content object
        $templateCode = null; //Hold the template source code.
        $conf["subpartMarker"] = "VIEW_MESSAGES_NEW_RESULT"; //Holds a subpart marker.
        $subSub_1 = "ADDITIONAL";

        // Get the html source between subpart markers from template file
        $templateCode = $cObj -> getSubpart($this -> orig_templateCode, "###" . $conf["subpartMarker"] . "###");

        /*
        * HANDLE ADDITIONAL
        */
        // Init subpart content
        $subpartContent = null;
        // Get link to messages
        $linkToMessages = $this -> pi_getPageLink($GLOBALS['TSFE']->id, "", array("action" => "getviewmessages", "uid" => $uid));
        // Create Marker Array
        $markerArray = array();
        $markerArray["###LINK_TO_MESSAGES###"] = $cObj -> stdWrap($linkToMessages, "");
				$markerArray["###SENT_MSG###"] = $cObj->stdWrap(htmlspecialchars($this->pi_getLL('CWT_MESSAGES_SENT')), "");  # mher
 				$markerArray["###BACK###"] = $cObj->stdWrap(htmlspecialchars($this->pi_getLL('CWT_MESSAGES_BACK')), "");  # mher
        // Substitute the markers in the given sub sub part.
        $subpartContent .= $cObj -> substituteMarkerArray($cObj -> getSubpart($templateCode, "###" . $subSub_1 . "###"), $markerArray);
        // Substitute the template code with the given subpartcontent.
        $templateCode = $this -> cObj -> substituteSubpart($templateCode, $subSub_1, $subpartContent);
        // Return the generated content

        $content = $templateCode;
        ###marker - email###
        $empfaenger = $_GET["recipient_uid"];
        $abfrage = "SELECT email, gender, first_name, last_name FROM fe_users WHERE uid = ".$empfaenger;
        $ergebnis = mysql_query($abfrage);
        while($row = mysql_fetch_object($ergebnis))
    	    {
	          $emailempfaenger = $row->email;
            $geschlecht = $row->gender;
            $vorname = $row->first_name;
            $nachname = $row->last_name;
	        }
          if($geschlecht == "0")
          {
          $anrede = "Lieber ";
          }
          else
          {
          $anrede = "Liebe ";
          }
          #echo $empfaenger;
          mail($emailempfaenger, "Eine neue Nachricht", $anrede.$vorname."\nDu hast eine neue Nachricht erhalten.")

        return $content;
    }
Dario ·

Neee, daran liegt es nicht!

das "return" habe ich schon an richtiger Stelle.

Grüße

Dario

Dario ·
    function getViewMessagesNewResult($uid, $recipient_uid)
    {
        // Init Vars
        $action = "getviewmessagesnewresult";
        $content = "";
        $cObj = $this -> cObj; //Holds a typo content object
        $templateCode = null; //Hold the template source code.
        $conf["subpartMarker"] = "VIEW_MESSAGES_NEW_RESULT"; //Holds a subpart marker.
        $subSub_1 = "ADDITIONAL";

        // Get the html source between subpart markers from template file
        $templateCode = $cObj -> getSubpart($this -> orig_templateCode, "###" . $conf["subpartMarker"] . "###");

		        /*
        * HANDLE ADDITIONAL
        */
        // Init subpart content
        $subpartContent = null;
        // Get link to messages
        $linkToMessages = $this -> pi_getPageLink($GLOBALS['TSFE']->id, "", array("action" => "getviewmessages", "uid" => $uid));
        // Create Marker Array
        $markerArray = array();
        $markerArray["###LINK_TO_MESSAGES###"] = $cObj -> stdWrap($linkToMessages, "");
		$markerArray["###SENT_MSG###"] = $cObj->stdWrap(htmlspecialchars($this->pi_getLL('CWT_MESSAGES_SENT')), "");  # mher
 		$markerArray["###BACK###"] = $cObj->stdWrap(htmlspecialchars($this->pi_getLL('CWT_MESSAGES_BACK')), "");  # mher
        // Substitute the markers in the given sub sub part.
        $subpartContent .= $cObj -> substituteMarkerArray($cObj -> getSubpart($templateCode, "###" . $subSub_1 . "###"), $markerArray);
        // Substitute the template code with the given subpartcontent.
        $templateCode = $this -> cObj -> substituteSubpart($templateCode, $subSub_1, $subpartContent);
        // Return the generated content
        $content = $templateCode;
		
		// E-Mail Benachrichtigung
		
		$empfaenger = $_GET["recipient_uid"];
        $abfrage = "SELECT email FROM fe_users WHERE uid = ".$empfaenger;
        $ergebnis = mysql_query($abfrage);
        while($row = mysql_fetch_object($ergebnis)) !!! DAS IST FEHLERZEILE !!!
            {
                  $emailempfaenger = $row->email;
                }
		// echo $row->email;
           mail($emailempfaenger, "Sie haben eine neue Nachricht erhalten", "Also auf und lesen!");
		   
		return $content;
	
   }
sobi555 ·

Uff... also jetzt bin ich echt überfragt. Bei mir läuft es so wie du es gepostet hast. Versuche folgendes, dass du die mail() Zeile wie folgt umstellst:
mail("deine@emai.de", "Eine neue Nachricht", "text");
Setze da mal deine richtige Mail rein und schau ob du eine eMail erhälst... Der Code wird bei mir ausgeührt, bei dir scheinbar nicht. Also von hier aus kann ich dir nicht mehr viel helfen. Also entweder liegen alle Mails im Spam oder was weiß ich! 🙂

LG - Simon

Dario ·

Vielen lieben Dank für Deine Mühe,

ich melde mich hier wenn ich denn Fehler gefunden habe.

Grüße

Dario

sobi555 ·

Ich weiß nicht wie deine Seite aussieht, aber eine Vermutung ist, dass evtl der "echobefehl" den Text "weiß auf weiß" ausgibt... im Quelltext nachschauen. Und ansonsten mit einfachen "echobefehlen" ausloten bis wo das Script läuft, ob es überhaupt durchläuft... wie auch immer! 🙂
Alternativ kann ich dir noch meine komplette Datei schicken... Aber jetzt geh ich erstmal schlafen! 🙂
LG - Simon