b8ea4ed6 |
1 | <? |
2 | /** smtp.php |
3 | ** |
4 | ** This contains all the functions needed to send messages through |
5 | ** an smtp server. |
6 | **/ |
7 | |
8 | function smtpReadData($smtpConnection) { |
9 | $read = fgets($smtpConnection, 1024); |
10 | $counter = 0; |
11 | while ($read) { |
12 | echo $read . "<BR>"; |
13 | $data[$counter] = $read; |
14 | $read = fgets($smtpConnection, 1024); |
15 | $counter++; |
16 | } |
17 | } |
18 | |
19 | function sendMessage($to, $subject, $body) { |
20 | echo "<FONT FACE=\"Arial,Helvetica\">"; |
21 | $smtpConnection = fsockopen("10.4.1.1", 25, $errorNumber, $errorString); |
22 | if (!$smtpConnection) { |
23 | echo "Error connecting to SMTP Server.<br>"; |
24 | echo "$errorNumber : $errorString<br>"; |
25 | exit; |
26 | } |
27 | echo htmlspecialchars(fgets($smtpConnection, 1024)) . "<BR>"; |
28 | |
29 | fputs($smtpConnection, "MAIL FROM:<luke@usa.om.org>\n"); |
30 | echo htmlspecialchars(fgets($smtpConnection, 1024)) . "<BR>"; |
31 | |
32 | fputs($smtpConnection, "RCPT TO:<$to>\n"); |
33 | echo htmlspecialchars(fgets($smtpConnection, 1024)) . "<BR>"; |
34 | |
35 | fputs($smtpConnection, "DATA\n"); |
36 | echo htmlspecialchars(fgets($smtpConnection, 1024)) . "<BR>"; |
37 | |
38 | fputs($smtpConnection, "Subject: $subject\n"); |
39 | fputs($smtpConnection, "$body\n"); |
40 | fputs($smtpConnection, ".\n"); |
41 | echo htmlspecialchars(fgets($smtpConnection, 1024)) . "<BR>"; |
42 | |
43 | fputs($smtpConnection, "QUIT\n"); |
44 | echo htmlspecialchars(fgets($smtpConnection, 1024)) . "<BR>"; |
45 | echo "</FONT>"; |
46 | } |
47 | ?> |