-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbouncelimit.c
60 lines (46 loc) · 1.12 KB
/
bouncelimit.c
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
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
int main() {
// read SMTPMAILFROM and SMTPRCPTCOUNT from environment
const char* smtpmailfrom = getenv("SMTPMAILFROM");
const char* smtprcptcount = getenv("SMTPRCPTCOUNT");
if (smtpmailfrom == NULL) {
smtpmailfrom = "";
}
if (smtprcptcount == NULL) {
printf("\n");
exit(0);
}
// long rcptcount = strtol(smtprcptcount, NULL, 10);
int rcptcount = toString(smtprcptcount);
if ( (strcmp(smtpmailfrom, "") == 0) &&
(rcptcount >= 1) ) {
fprintf(stderr, "%d Empty envelope sender with multiple recipients from %s\n", getpid(), getenv("TCPREMOTEIP"));
printf("E550 Bounces should only have one recipient\n");
} else {
printf("\n");
}
exit(0);
}
int toString(char a[]) {
int c, sign, offset, n;
if (a[0] == '-') { // Handle negative integers
sign = -1;
}
if (sign == -1) { // Set starting position to convert
offset = 1;
}
else {
offset = 0;
}
n = 0;
for (c = offset; a[c] != '\0'; c++) {
n = n * 10 + a[c] - '0';
}
if (sign == -1) {
n = -n;
}
return n;
}