struct usersupp vrfy_buffer;
int vrfy_count;
char vrfy_match[256];
+ char from[256];
};
enum {
cprintf("214- EXPN\n");
cprintf("214- HELO\n");
cprintf("214- HELP\n");
+ cprintf("214- MAIL\n");
cprintf("214- NOOP\n");
cprintf("214- QUIT\n");
cprintf("214- RSET\n");
*/
void smtp_rset(void) {
memset(SMTP, 0, sizeof(struct citsmtp));
+ if (CC->logged_in) logout(CC);
cprintf("250 Zap!\n");
}
+/*
+ * Implements the "MAIL From:" command
+ */
+void smtp_mail(char *argbuf) {
+ char user[256];
+ char node[256];
+ int cvt;
+
+ if (strlen(SMTP->from) != 0) {
+ cprintf("503 Only one sender permitted\n");
+ return;
+ }
+
+ if (strncasecmp(argbuf, "From:", 5)) {
+ cprintf("501 Syntax error\n");
+ return;
+ }
+
+ strcpy(SMTP->from, &argbuf[5]);
+ striplt(SMTP->from);
+
+ if (strlen(SMTP->from) == 0) {
+ cprintf("501 Empty sender name is not permitted\n");
+ return;
+ }
+
+
+ /* If this SMTP connection is from a logged-in user, make sure that
+ * the user only sends email from his/her own address.
+ */
+ if (CC->logged_in) {
+ lprintf(9, "Me-checking <%s>\n", SMTP->from);
+ cvt = convert_internet_address(user, node, SMTP->from);
+ lprintf(9, "cvt=%d, citaddr=<%s@%s>\n", cvt, user, node);
+ if ( (cvt != 0) || (strcasecmp(user, CC->usersupp.fullname))) {
+ cprintf("550 <%s> is not your address.\n", SMTP->from);
+ strcpy(SMTP->from, "");
+ return;
+ }
+ }
+
+ cprintf("250 Sender ok. Groovy.\n");
+}
+
+
+
/*
* Main command loop for SMTP sessions.
*/
smtp_help();
}
+ else if (!strncasecmp(cmdbuf, "MAIL", 4)) {
+ smtp_mail(&cmdbuf[5]);
+ }
+
else if (!strncasecmp(cmdbuf, "NOOP", 4)) {
cprintf("250 This command successfully did nothing.\n");
}