/usr/share/ecere/extras/SMTPSocket.ec is in ecere-extras 0.44.15-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 | #ifdef ECERE_STATIC
public import static "ecere"
#else
public import "ecere"
#endif
// define app = ((MyApp)__thisModule);
class SMTPSocket : Socket
{
bool replied;
uint OnReceive(const byte * buffer, uint count)
{
/*#ifdef _DEBUG
int c;
for(c = 0; c<count; c++)
putch(buffer[c]);
#endif*/
replied = true;
return count;
}
void OnDisconnect(int code)
{
replied = true;
}
void WaitReply()
{
while(!replied)
Process();
replied = false;
}
};
void SMTPSend(char * host, char * to, char * from, File file)
{
SMTPSocket socket { };
incref socket;
if(socket.Connect(host, 25)) //995
{
socket.WaitReply();
Log("HELO localhost\n");
socket.SendString("HELO localhost\r\n");
socket.WaitReply();
Logf("MAIL from: %s\n", from);
socket.Sendf("MAIL from: %s\r\n", from);
socket.WaitReply();
Logf("RCPT To: %s\n", to);
socket.Sendf("RCPT To: %s\r\n", to);
socket.WaitReply();
Log("DATA\n");
socket.SendString("DATA\r\n");
socket.WaitReply();
Log("Subject: Email test\n");
Log("Mime-Version: 1.0;\n");
Log("Content-Type: text/html; charset=\"ISO-8859-1\";\n");
Log("Content-Transfer-Encoding: 7bit;\n");
socket.SendString("Subject: Email test\r\n");
socket.SendString("Mime-Version: 1.0;\r\n");
socket.SendString("Content-Type: text/html; charset=\"ISO-8859-1\";\r\n");
socket.SendString("Content-Transfer-Encoding: 7bit;\r\n");
socket.SendString("\r\n");
file.Seek(0, start);
while(!file.Eof())
{
char buffer[4096];
uint read = file.Read(buffer, 1, sizeof(buffer));
socket.Send(buffer, read);
}
Log("\n.\n");
socket.SendString("\r\n.\r\n");
socket.WaitReply();
Log("QUIT\n");
socket.SendString("QUIT\r\n");
socket.WaitReply();
socket.Disconnect(0);
}
delete socket;
}
/*
class MyApp : GuiApplication
{
void Main()
{
File f = FileOpen("http://server/dir/", read);
if(f)
Send("mail.server.ca", "user@mail.com", "user@server.com", f);
delete f;
getch();
}
}
*/
|