SMTP Relay quetions - WeOnlyDo Discussion board

SMTP Relay quetions (wodSmtpServer / wodPop3Server / wodImapServer)

by bkv, Thursday, June 09, 2011, 08:46 (4702 days ago)

Hello,
Could you pls clarify how the SMTP relay has to work.

Situation:
My SMTP server fires several MailTo events (client sends RCPT TO command more than once).
What I have to do if some addresses belong to my server and some not,
in situation when relay is allowed and not allowed.
1) Relay is not allowed
- I have to deny sending message if even one of the addresses not belongs to my SMTP? But in this case my users also will not get this message.
2) Relay allowed.
- I detected what addresses belongs to my SMTP, save message to user mailboxes, than I have to relay it. But what I have to do with my addresses in relayed message to don`t get that message again. I have to somehow to remove it from MailTO?

Thanks in advanced.


Re: SMTP Relay quetions

by woddrazen, Thursday, June 09, 2011, 09:55 (4702 days ago) @ bkv

Hi,


Why don't you check inside wodSmtpServer Events value of User.Message.MailTo. If you want to relay some messages you can do that inside MailReceived Event.

Can you maybe try something like that?

Let us know how it goes.


Regards,
Drazen

Re: SMTP Relay quetions

by bkv, Thursday, June 09, 2011, 10:38 (4702 days ago) @ woddrazen

Check to what? And what to do than?

Re: SMTP Relay quetions

by bkv, Thursday, June 09, 2011, 10:42 (4702 days ago) @ bkv

The question is about right behaviour.
How it has to be?

1) Relay is not allowed
- I have to deny sending message if even one of the addresses not belongs to my SMTP? But in this case my users also will not get this message.
So I have to deny messages which are send not only to me?

2) Relay allowed.
- I detected what addresses belongs to my SMTP, save message to user mailboxes, than I have to relay it. But what I have to do with my addresses in relayed message to don`t get that message again. I have to somehow to remove it from MailTO?
What step by step action have to be in this case?


Thanks.

Re: SMTP Relay quetions

by woddrazen, Thursday, June 09, 2011, 11:50 (4702 days ago) @ bkv

Hi,


You want to use standard procedure for relaying messages?

You can find more info here:
http://www.weonlydo.com/SmtpServer/Help/Relaying.html


Drazen

Re: SMTP Relay quetions

by bkv, Thursday, June 09, 2011, 12:23 (4702 days ago) @ woddrazen

I want to use standard procedure for relaying messages.

In article you provided there is no information how to handle situation when in one message there are addresses which are own (belong to current SMTP) and have to be relayed.
I am asking only about this situation.
To don`t produce a lot of posts, lets better look at example:

My SMTP server is responsible for address: addr@mydomain.com.
Message is sending to two addreses: addr@mydomain.com and addr@relaydomain.com.

First situation - Relay is not allowed at my SMTP:
In MailTo event I am checking addresses.
addr@mydomain.com-OK, my address(Action=SmtpActions.Allow);
addr@relaydomain.com.-Not my address(Action=mtpActions.Deny;)
Looks ok, I accepted my address and refused another. But in real, if set Action=mtpActions.Deny even for one address in Mailto event, the message sending will be aborted. And my local user also will not get this message. Is it correct?

Second situation - Relay is allowed at my SMTP:
In MailTo event I am checking addresses.
addr@mydomain.com-OK, my address(Action=SmtpActions.Allow);
addr@relaydomain.com.- OK, not my addres (Action=mtpActions.Allow;)
Now, in MailReceived event I have to relay it. But before I have to remove from destinations my own address addr@mydomain.com. Right? How?

Re: SMTP Relay quetions

by woddrazen, Thursday, June 09, 2011, 12:59 (4702 days ago) @ bkv

Hi,


About your first issue. In order for email to be relayed you need to provide that message to SmtpRelay object inside MailReceived Event.

So if you don't do that, that message will not be relayed and still it will be saved because MailTo Event is fired before.

About your second issue, you can change MailTo value inside MailReceived Event just before you add message to SmtpRelay object.

Something like this:
[code]User.Message.MailTo = only_relay_email
wodSmtpServer1.Relays.Add User.Message[/code]
Let us know how it goes.


Drazen

Re: SMTP Relay quetions

by bkv, Thursday, June 09, 2011, 14:05 (4702 days ago) @ woddrazen

Thanks for answer.

About your first issue.
- First issue is when relay is denied for my smtp server = SMTP server is accepting only own email addresses. And the question is how it has to react in this case when message contain not only own addresses???

Second situation - Relay is allowed at my SMTP
- Now we are a bit close. So, inside MailReceived Event I have to remove own addresses from User.Message.MailTo and relay message using wodSmtpServer1.Relays.Add. Right?


Re: SMTP Relay quetions

by woddrazen, Thursday, June 09, 2011, 14:53 (4702 days ago) @ bkv

Hi,


You should allow relaying sender of the message or the receiver is a local user. You mention multiple recipient, who s sending this message local user or someone else?

Yes, you can remove your own address inside MailTo Property in MailReceived Event.


Drazen