void HandleSMTPData(smtp_node *smtp) { char s[SMTP_MAX_LINE]; if (smtp->forward_path == NULL || smtp->reverse_path == NULL) { smtpprintf(smtp,"503 Bad sequence of commands"); return; } sprintf(s,"Return-Path: <%s>\r\n",smtp->reverse_path); AddSMTPDataLine(smtp,s); sprintf(s,"Received: from %s by %s with SMTP ; %s\r\n",smtp->source_name, GetLocalMachineName(),SMTPTimeStr(GetTime())); AddSMTPDataLine(smtp,s); smtp->state = SMTP_DATA; smtpprintf(smtp,"354 Send mail now; end with <CRLF>.<CRLF>"); }
/* this function is run in its own thread */ void __cdecl ThreadHandleSMTPConnection(void *param) { smtp_node *smtp = (smtp_node *) param; /* gotta free the smtp node when done--allocated by AsyncSMTPSocketConnect in async.c */ smtpprintf(smtp,"220 %s Ready to go",GetLocalMachineName()); while (smtp->state != SMTP_QUIT && smtp->state != SMTP_ERROR) { ReadSMTPLine(smtp); } if (ConfigBool(DEBUG_SMTP)) dprintf("SMTP Disconnection: %s\n",smtp->source_name); ClearSMTPBuffers(smtp); closesocket(smtp->sock); FreeMemory(MALLOC_ID_SMTP,smtp,sizeof(smtp_node)); }
/*---------------------------------------------------------------------------------------------- Retrieves the name of the local host, placing it into the class member variable. Returns true if successful, false otherwise. ----------------------------------------------------------------------------------------------*/ bool NetworkTreeView::_GetLocalMachineName() { return GetLocalMachineName(m_szLocalMachineName, sizeof(m_szLocalMachineName)); }
void HandleSMTPRecipient(smtp_node *smtp) { char *s,*dest_machine; string_list *sl; /* Syntax for this command is RCPT TO:<*****@*****.**> */ s = strtok(NULL," \t\r\n"); if (s == NULL) { smtpprintf(smtp,"501 Syntax error, no parameter"); return; } if (strnicmp(s,"TO:<",4) != 0) { smtpprintf(smtp,"501 Syntax error, parameter doesn't start to:<"); return; } if (s[strlen(s)-1] != '>') { smtpprintf(smtp,"501 Syntax error, parameter doesn't end >"); return; } s[strlen(s)-1] = 0; /* kill off the > */ s += 4; /* skip over the to:< */ /* check if there's a colon, which means it should be forwarded */ if (strchr(s,':') != 0) { smtpprintf(smtp,"550 Can't forward (To:<xxx> had a :)"); return; } /* make sure there's an @, and get the name & machine name */ if (strchr(s,'@') == NULL) { smtpprintf(smtp,"550 Can't find destination (To:<xxx> had no @)"); return; } s = strtok(s,"@"); dest_machine = strtok(NULL,"@"); if (s == NULL || dest_machine == NULL) { smtpprintf(smtp,"550 Can't find destination person or machine"); return; } if (stricmp(dest_machine,GetLocalMachineName()) != 0) { smtpprintf(smtp,"550 Can only send mail to this machine (%s)",GetLocalMachineName()); return; } /* dprintf("recipient %s\n",s); */ /* check if the person in s is a local user */ if (ExistInternetMailName(s) == False) { smtpprintf(smtp,"550 No user by the name %s here\n",s); return; } /* insert node on front of string list which is the destinations */ sl = (string_list *) AllocateMemory(MALLOC_ID_SMTP,sizeof(string_list)); sl->str = (char *) AllocateMemory(MALLOC_ID_SMTP,strlen(s)+1); strcpy(sl->str,s); sl->next = smtp->forward_path; smtp->forward_path = sl; smtpprintf(smtp,"250 Ok"); }