|
Home > Archive > IIS and SMTP > December 2005 > Protocol Event Sink
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
Protocol Event Sink
|
|
| Junk Mail 2005-11-24, 5:54 pm |
| I am not a C++ programmer, but still I need to create a 'White List
function' on my SMTP Server at protocol level, because I need to terminate
the SMTP connection...
I tried to build the ShieldsUp Protocol Event Sink with ATL
http://msdn.microsoft.com/library/e...dc8d82c93d4.asp
I can compile but, I can't register the event
Can anyone help me?
I can't attatch the project, but if you can help me, I will send the Zip
file
| |
| Junk Mail 2005-11-24, 5:54 pm |
| Now I got the sample to work... not easy for at none C++ guy :-)
I can now close the smtp connection with this code, but how do I get til
senders ip address?
/*
** ISmtpInCommandSink
*/
STDMETHODIMP CSink::OnSmtpInCommand(
IUnknown *pServer,
IUnknown *pSession,
IMailMsgProperties *pMsg,
ISmtpInCommandContext *pContext)
{
HRESULT hr = S_OK;
if(pContext == NULL)
return E_POINTER;
char* pszResponse = NULL;
long lResponseLength = strlen(g_szResponseText);
pszResponse = (char*) CoTaskMemAlloc(g_dwResponseSize);
strcpy(pszResponse,g_szResponseText);
pszResponse[g_dwResponseSize-1] = '\0';
hr = pContext->SetResponse(pszResponse, g_dwResponseSize);
if(FAILED(hr))
return hr;
hr = pContext->SetSmtpStatusCode(550);
if(FAILED(hr))
return hr;
hr = pContext->SetCommandStatus(EXPE_DROP_SESSION);
if(FAILED(hr))
return hr;
// Success.
// Notify the dispatcher that we have
// consummed the event.
// No other sinks will run, and
// the connection will be dropped.
return EXPE_S_CONSUMED;
}
| |
| Egbert Nierop \(MVP for IIS\) 2005-11-25, 7:49 am |
|
"Junk Mail" <a54857@hotmail.com> wrote in message
news:OgvlZpU8FHA.4084@TK2MSFTNGP10.phx.gbl...
> Now I got the sample to work... not easy for at none C++ guy :-)
>
> I can now close the smtp connection with this code, but how do I get til
> senders ip address?
I got this working as well. It uses Active Directory as a whitelist
container.
The difficulties exist at the documentation level. MS did not document this
too well, since it would be against there own Exchange product 
| |
| Junk Mail 2005-11-28, 7:50 am |
| Is it possible to get you code?
"Egbert Nierop (MVP for IIS)" <egbert_nierop@nospam.invalid> wrote in
message news:O3Og9Oc8FHA.2192@TK2MSFTNGP14.phx.gbl...
>
> "Junk Mail" <a54857@hotmail.com> wrote in message
> news:OgvlZpU8FHA.4084@TK2MSFTNGP10.phx.gbl...
>
> I got this working as well. It uses Active Directory as a whitelist
> container.
> The difficulties exist at the documentation level. MS did not document
> this too well, since it would be against there own Exchange product 
>
>
| |
| Johan Karl Larsen 2005-12-01, 8:55 pm |
|
"Junk Mail" <a54857@hotmail.com> wrote in message
news:OgvlZpU8FHA.4084@TK2MSFTNGP10.phx.gbl...
> Now I got the sample to work... not easy for at none C++ guy :-)
>
> I can now close the smtp connection with this code, but how do I get til
> senders ip address?
>
You could read a property from IMailMsgProperties:
CHAR szBuf[100];
if (pMsg) // This interface pointer will only be initialized after "MAIL
FROM: <user@domain>"
{
hr = pMsg-> GetStringA(IMMPID_MP_CONNECTION_IP_ADDRE
SS, sizeof(szBuf),
szBuf);
......
}
where IMMPID_MP_CONNECTION_IP_ADDRESS is defined in mailmsgprops.h (Platform
SDK).
--
Johan
|
|
|
|
|