Removed obsolete file. mail.local provides the same functionality.
Showing
1 changed file
with
0 additions
and
99 deletions
examples/mail.MysqlMailer.c
deleted
100644 → 0
1 | #include <stdlib.h> | ||
2 | #include <stdio.h> | ||
3 | #include <mysql/mysql.h> | ||
4 | #include <unistd.h> | ||
5 | #include <string.h> | ||
6 | #include <sysexits.h> | ||
7 | #include <sys/types.h> | ||
8 | #include <sys/stat.h> | ||
9 | |||
10 | /********************************************************************** | ||
11 | ** mailer to go with gnu-pop3d patch, works with sendmail | ||
12 | ** add the following in sendmail.cf right after virtusertable ruleset | ||
13 | ** R$* < $* @ yourdomain . net . > $#MysqlMailer $: $1 | ||
14 | ** | ||
15 | ** Then after local mailer, add the following | ||
16 | ** MMysqlMailer, P=/usr/local/bin/mail.MysqlMailer, F=lsDFMoqeu9, S=10/30, R=20/40, | ||
17 | ** A=mail.MysqlMailer $u | ||
18 | ** | ||
19 | ** compile with gcc -o mail.MysqlMailer mail.MysqlMailer.c -lmysqlclient | ||
20 | ** | ||
21 | ** chown it so it is owned by same owner of your psuedo mails (mine is monly) | ||
22 | ** and same group as owner sendmail runs as | ||
23 | ** then chmod 4711. If you have local users on your box (shell accounts) you may want | ||
24 | ** to declare AGENT as read-only in /etc/profile (declare -r AGENT). | ||
25 | ** | ||
26 | ** Author: Jim Hull (08-24-2001) | ||
27 | ** imaginos@imaginos.net | ||
28 | **********************************************************************/ | ||
29 | |||
30 | #define USERNAME "username" /* username field */ | ||
31 | #define TABLE "table" /* table name */ | ||
32 | #define Muser "user" /* Mysql username */ | ||
33 | #define Mpass "password" /* Mysql password */ | ||
34 | #define Mdb "db" /* Mysql Database Name */ | ||
35 | |||
36 | int main(int argc, char **argv) | ||
37 | { | ||
38 | FILE *f; | ||
39 | char QueryStr[1024], *user, path[128], output[1024], *agent; | ||
40 | MYSQL *m; | ||
41 | MYSQL_RES *res; | ||
42 | MYSQL_ROW row; | ||
43 | int i; | ||
44 | |||
45 | if (argc != 2) | ||
46 | exit(EX_NOUSER); | ||
47 | |||
48 | agent = getenv("AGENT"); | ||
49 | |||
50 | if (!agent) | ||
51 | exit(EX_NOUSER); | ||
52 | |||
53 | if (strcmp(getenv("AGENT"), "sendmail") != 0) | ||
54 | exit(EX_NOUSER); | ||
55 | |||
56 | user = strdup(argv[1]); | ||
57 | |||
58 | memset((char *)QueryStr, '\0', 1024); | ||
59 | memset((char *)path, '\0', 128); | ||
60 | |||
61 | m = mysql_init(0); | ||
62 | |||
63 | if (!m) | ||
64 | exit(EX_NOUSER); | ||
65 | |||
66 | if (!mysql_real_connect(m, NULL, Muser, Mpass, Mdb, 0, NULL, 0)) | ||
67 | exit(EX_NOUSER); | ||
68 | |||
69 | sprintf(QueryStr, "select %s from %s where %s = '%s' limit 1", USERNAME, TABLE, USERNAME, user); | ||
70 | |||
71 | if (mysql_query(m, QueryStr) != 0) | ||
72 | exit(EX_NOUSER); | ||
73 | |||
74 | if ((res = mysql_store_result(m)) == NULL) | ||
75 | exit(EX_NOUSER); | ||
76 | |||
77 | if ((row = mysql_fetch_row(res)) == NULL) | ||
78 | exit(EX_NOUSER); | ||
79 | |||
80 | sprintf(path, "/var/spool/mail/%s", row[0]); | ||
81 | |||
82 | f = fopen(path, "a"); | ||
83 | |||
84 | if (!f) | ||
85 | exit(EX_NOUSER); | ||
86 | |||
87 | while (!feof(stdin)) | ||
88 | { | ||
89 | memset((char *)output, '\0', 1024); | ||
90 | fgets(output, 1024, stdin); | ||
91 | fprintf(f, "%s", output); | ||
92 | } | ||
93 | chmod(path, S_IWUSR|S_IRUSR|S_IRGRP|S_IWGRP); | ||
94 | fclose(f); | ||
95 | exit(0); | ||
96 | } | ||
97 | |||
98 | |||
99 |
-
Please register or sign in to post a comment