示例#1
0
int pop3_do_fetching(pop3aggr *cpptr)
{
	AsyncIO *IO = &cpptr->IO;

	InitIOStruct(IO,
		     cpptr,
		     eReadMessage,
		     POP3_C_ReadServerStatus,
		     POP3_C_DNSFail,
		     POP3_C_DispatchWriteDone,
		     POP3_C_DispatchReadDone,
		     POP3_C_Terminate,
		     POP3_C_TerminateDB,
		     POP3_C_ConnFail,
		     POP3_C_Timeout,
		     POP3_C_Shutdown);

	safestrncpy(((CitContext *)cpptr->IO.CitContext)->cs_host,
		    ChrPtr(cpptr->Url),
		    sizeof(((CitContext *)cpptr->IO.CitContext)->cs_host));

	if (cpptr->IO.ConnectMe->IsIP) {
		QueueEventContext(&cpptr->IO,
				  pop3_connect_ip);
	}
	else {
		QueueEventContext(&cpptr->IO,
				  pop3_get_one_host_ip);
	}
	return 1;
}
示例#2
0
void smtp_try_one_queue_entry(OneQueItem *MyQItem,
			      MailQEntry *MyQEntry,
			      StrBuf *MsgText,
			/*KeepMsgText allows us to use MsgText as ours.*/
			      int KeepMsgText,
			      int MsgCount)
{
	SmtpOutMsg *Msg;

	SMTPC_syslog(LOG_DEBUG, "%s\n", __FUNCTION__);

	Msg = new_smtp_outmsg(MyQItem, MyQEntry, MsgCount);
	if (Msg == NULL) {
		SMTPC_syslog(LOG_DEBUG, "%s Failed to alocate message context.\n", __FUNCTION__);
		if (KeepMsgText) 
			FreeStrBuf (&MsgText);
		return;
	}
	if (KeepMsgText) Msg->msgtext = MsgText;
	else		 Msg->msgtext = NewStrBufDup(MsgText);

	if (smtp_resolve_recipients(Msg) &&
	    (!MyQItem->HaveRelay ||
	     (MyQItem->URL != NULL)))
	{
		safestrncpy(
			((CitContext *)Msg->IO.CitContext)->cs_host,
			Msg->node,
			sizeof(((CitContext *)
				Msg->IO.CitContext)->cs_host));

		SMTPC_syslog(LOG_DEBUG, "Starting: [%ld] <%s> CC <%d> \n",
			     Msg->MyQItem->MessageID,
			     ChrPtr(Msg->MyQEntry->Recipient),
			     ((CitContext*)Msg->IO.CitContext)->cs_pid);
		if (Msg->pCurrRelay == NULL) {
			SetSMTPState(&Msg->IO, eSTMPmxlookup);
			QueueEventContext(&Msg->IO,
					  resolve_mx_records);
		}
		else { /* oh... via relay host */
			Msg->IsRelay = 1;
			if (Msg->pCurrRelay->IsIP) {
				SetSMTPState(&Msg->IO, eSTMPconnecting);
				QueueEventContext(&Msg->IO,
						  mx_connect_ip);
			}
			else {
				SetSMTPState(&Msg->IO, eSTMPalookup);
				/* uneducated admin has chosen to
				   add DNS to the equation... */
				QueueEventContext(&Msg->IO,
						  get_one_mx_host_ip);
			}
		}
	}
	else {
		SetSMTPState(&Msg->IO, eSMTPFailTotal);
		/* No recipients? well fail then. */
		if (Msg->MyQEntry != NULL) {
			Msg->MyQEntry->Status = 5;
			if (StrLength(Msg->MyQEntry->StatusMessage) == 0)
				StrBufPlain(Msg->MyQEntry->StatusMessage,
					    HKEY("Invalid Recipient!"));
		}
		FinalizeMessageSend_DB(&Msg->IO);
		DeleteSmtpOutMsg(Msg);
	}
}