Composing messages works great!
authorlkehresman <lkehresman@7612ce4b-ef26-0410-bec9-ea0150e637f0>
Sat, 4 Dec 1999 21:42:37 +0000 (21:42 +0000)
committerlkehresman <lkehresman@7612ce4b-ef26-0410-bec9-ea0150e637f0>
Sat, 4 Dec 1999 21:42:37 +0000 (21:42 +0000)
git-svn-id: https://svn.code.sf.net/p/squirrelmail/code/trunk/squirrelmail@59 7612ce4b-ef26-0410-bec9-ea0150e637f0

functions/smtp.php
functions/strings.php
src/compose.php
src/compose_send.php

index bae3ccb..d2865be 100644 (file)
       }
    }
 
-   function sendMessage($smtpServerAddress, $smtpPort, $to, $subject, $body) {
-      $to = addslashes($to);
-      $body = addslashes($body);
+   function sendMessage($smtpServerAddress, $smtpPort, $username, $domain, $t, $c, $b, $subject, $body, $version) {
+      $to = parseAddrs($t);
+      $cc = parseAddrs($c);
+      $bcc = parseAddrs($b);
+      $body = $body;
       $from = "$username@$domain";
 
       echo "<FONT FACE=\"Arial,Helvetica\">";
          echo "$errorNumber : $errorString<br>";
          exit;
       }
-      echo htmlspecialchars(fgets($smtpConnection, 1024)) . "<BR>";
 
+      $to_list = getLineOfAddrs($to);
+      $cc_list = getLineOfAddrs($cc);
+
+      /** Lets introduce ourselves */
+      fputs($smtpConnection, "HELO $domain\n");
+      /** Ok, who is sending the message? */
       fputs($smtpConnection, "MAIL FROM:<$from>\n");
-      echo htmlspecialchars(fgets($smtpConnection, 1024)) . "<BR>";
 
-      fputs($smtpConnection, "RCPT TO:<$to>\n");
-      echo htmlspecialchars(fgets($smtpConnection, 1024)) . "<BR>";
+      /** send who the recipients are */
+      for ($i = 0; $i < count($to); $i++) {
+         fputs($smtpConnection, "RCPT TO:<$to[$i]>\n");
+      }
+      for ($i = 0; $i < count($cc); $i++) {
+         fputs($smtpConnection, "RCPT TO:<$cc[$i]>\n");
+      }
+      for ($i = 0; $i < count($bcc); $i++) {
+         fputs($smtpConnection, "RCPT TO:<$bcc[$i]>\n");
+      }
 
+      /** Lets start sending the actual message */
       fputs($smtpConnection, "DATA\n");
-      echo htmlspecialchars(fgets($smtpConnection, 1024)) . "<BR>";
-
-      fputs($smtpConnection, "Subject: $subject\n");
-      fputs($smtpConnection, "Date: " . date() . "\n");
-      fputs($smtpConnection, "To: <$to>\n");
-      fputs($smtpConnection, "From: <$from>\n");
-      fputs($smtpConnection, "$body\n");
-      fputs($smtpConnection, ".\n");
-      echo htmlspecialchars(fgets($smtpConnection, 1024)) . "<BR>";
-
-      fputs($smtpConnection, "QUIT\n");
-      echo htmlspecialchars(fgets($smtpConnection, 1024)) . "<BR>";
+      fputs($smtpConnection, "Subject: $subject\n"); // Subject
+      fputs($smtpConnection, "To: <$to_list>\n");    // Who it's TO
+      if ($cc_list) {
+         fputs($smtpConnection, "Cc: <$cc_list>\n"); // Who the CCs are
+      }
+      fputs($smtpConnection, "X-Mailer: SquirrelMail (version $version)\n"); // Identify SquirrelMail
+
+      fputs($smtpConnection, "$body\n"); // send the body of the message
+      fputs($smtpConnection, ".\n"); // end the DATA part
+      fputs($smtpConnection, "QUIT\n"); // log off
+
       echo "</FONT>";
    }
 ?>
\ No newline at end of file
index d00cd83..348b62d 100644 (file)
       }
       return $line;
    }
+
+   /** Returns an array of email addresses **/
+   function parseAddrs($text) {
+      $text = str_replace(" ", "", $text);
+      $text = str_replace(",", ";", $text);
+      $array = explode(";", $text);
+      return $array;
+   }
+
+   /** Returns a line of comma separated email addresses from an array **/
+   function getLineOfAddrs($array) {
+      $to_line = "";
+      for ($i = 0; $i < count($array); $i++) {
+         if ($to_line)
+            $to_line = "$to_line, $array[$i]";
+         else
+            $to_line = "$array[$i]";
+      }
+      return $to_line;
+   }
 ?>
index e78c515..d88e087 100644 (file)
 
    echo "<FORM action=\"compose_send.php\" METHOD=POST>\n";
    echo "<CENTER>";
-   echo "<INPUT TYPE=TEXT NAME=passed_to>";
-   echo "<INPUT TYPE=TEXT NAME=passed_subject>";
-   echo "<TEXTAREA NAME=passed_body ROWS=20 COLS=72 WRAP=SOFT></TEXTAREA><BR>";
+   echo "<TABLE COLS=2 WIDTH=100% ALIGN=CENTER>\n";
+   echo "   <TR>\n";
+   echo "      <TD WIDTH=15% BGCOLOR=FFFFFF ALIGN=RIGHT>\n";
+   echo "         <FONT FACE=\"Arial,Helvetica\">To: </FONT>\n";
+   echo "      </TD><TD WIDTH=85% BGCOLOR=FFFFFF ALIGN=LEFT>\n";
+   echo "         <INPUT TYPE=TEXT NAME=passed_to SIZE=60><BR>";
+   echo "      </TD>\n";
+   echo "   </TR>\n";
+   echo "   <TR>\n";
+   echo "      <TD WIDTH=15% BGCOLOR=FFFFFF ALIGN=RIGHT>\n";
+   echo "         <FONT FACE=\"Arial,Helvetica\">CC:</FONT>\n";
+   echo "      </TD><TD WIDTH=85% BGCOLOR=FFFFFF ALIGN=LEFT>\n";
+   echo "         <INPUT TYPE=TEXT NAME=passed_cc SIZE=60><BR>";
+   echo "      </TD>\n";
+   echo "   </TR>\n";
+   echo "   <TR>\n";
+   echo "      <TD WIDTH=15% BGCOLOR=FFFFFF ALIGN=RIGHT>\n";
+   echo "         <FONT FACE=\"Arial,Helvetica\">BCC:</FONT>\n";
+   echo "      </TD><TD WIDTH=85% BGCOLOR=FFFFFF ALIGN=LEFT>\n";
+   echo "         <INPUT TYPE=TEXT NAME=passed_bcc SIZE=60><BR>";
+   echo "      </TD>\n";
+   echo "   </TR>\n";
+   echo "   <TR>\n";
+   echo "      <TD WIDTH=15% BGCOLOR=FFFFFF ALIGN=RIGHT>\n";
+   echo "         <FONT FACE=\"Arial,Helvetica\">Subject:</FONT>\n";
+   echo "      </TD><TD WIDTH=85% BGCOLOR=FFFFFF ALIGN=LEFT>\n";
+   echo "         <INPUT TYPE=TEXT NAME=passed_subject SIZE=60><BR>";
+   echo "      </TD>\n";
+   echo "   </TR>\n";
+   echo "</TABLE>\n";
+
+   echo "<TEXTAREA NAME=passed_body ROWS=20 COLS=72 WRAP=HARD></TEXTAREA><BR>";
    echo "<INPUT TYPE=SUBMIT VALUE=\"Send\">";
    echo "</CENTER>";
    echo "</FORM>";
index aba3ccf..b3d6a79 100644 (file)
@@ -1,3 +1,6 @@
+<HTML>
+<META HTTP-EQUIV="REFRESH" CONTENT="0;URL=right_main.php">
+<BODY TEXT="#000000" BGCOLOR="#FFFFFF" LINK="#0000EE" VLINK="#0000EE" ALINK="#0000EE">
 <?
    include("../config/config.php");
    include("../functions/strings.php");
@@ -5,6 +8,11 @@
    include("../functions/mailbox.php");
    include("../functions/smtp.php");
 
-   sendMessage($smtpServerAddress, $smtpPort, $passed_to, $passed_subject, $passed_body);
-   echo "<A HREF=\"right_main.php\">RETURN</A>";
-?>
\ No newline at end of file
+   sendMessage($smtpServerAddress, $smtpPort, $username, $domain, $passed_to, $passed_cc, $passed_bcc, $passed_subject, $passed_body, $version);
+
+   echo "<FONT FACE=\"Arial,Helvetica\">";
+   echo "<BR><BR><BR><CENTER><B>Message Sent!</B><BR><BR>";
+   echo "You will be automatically forwarded.<BR>If not, <A HREF=\"right_main.php\">click here</A>";
+   echo "</CENTER></FONT>";
+?>
+</BODY></HTML>
\ No newline at end of file