SMTP relay in case if message was sent to more the (wodSmtpServer / wodPop3Server / wodImapServer)
Hello WEONLYDO,
What is the best approach for message relay if it was sent to more than one recipient?
In you sample № 4. Only relays received messages you are using MailReceived event like:
Private Sub wodSmtpServer1_MailReceived(ByVal User As WODSMTPSERVERCOMLib.ISmtpUser, Action As WODSMTPSERVERCOMLib.SmtpActions)
PrintList *** Mail received from & User.HostName & ! Contents follows:
PrintList User.Message.Body
PrintList *** Adding message to be relayed to & User.Message.MailTo
wodSmtpServer1.Relays.Add User.Message
End Sub
But MailReceived event is raised only once, for all recipients, and message will be relayed to last recipient which is saved in User.Message.MailTo property.
How to relay to all recipients?
Thanks in advance.
Re: SMTP relay in case if message was sent to more
Hi,
Actually, although MailReceived is triggered once (single message is received), message will be relayed to all recepients in MailTo property.
Just make sure that each recepient is separated by CrLf.
Regards,
Damba
Re: SMTP relay in case if message was sent to more
Thanks,for reply.
Then question is the next. Lets say MailTo contains 4 addresses:
1) email1@gmail.com
2) email2@gmail.com
3) email1@hotmail.com
4) email2@hotmail.com
What SMTP server will be used to replay?
Will it detect that address 1 and 2 belong to gmail.com domain and address 3 and 4 belong to hotmail.com domain and split two two relays?
Re: SMTP relay in case if message was sent to more
Hi,
Unless SmartHost for the relay is specified, component will always try to use mail server of the recepient.
If you wish to specify which server to use, you'll need to create a new relay and specify the server you wish to use.
Regards,
Damba
Re: SMTP relay in case if message was sent to more
Ok, I have got another problem.
If one of the destination addresses is not correct, then whole relay failed. Message is not relayed to any destination;
Example: Message was send to three destinations. One of the, is not correct (e.g not existing email addres). I am relaying this message using SmtpRelay smtpRelay = smtpserver.Relays.Add(User.Message);
The RelayError event is raized and message is not relayed to other correct addresses.
Re: SMTP relay in case if message was sent to more
Hi,
Ok, but that's why the Error event was triggered. Why not simply useit to remove the problematic address from the relay object, and call it's Retry method?
Regards,
Damba
Re: SMTP relay in case if message was sent to more
I don`t know, thats why I am asking :)
But the problem is that in the Error event it is not possible to detect what exactly address caused problem.
Re: SMTP relay in case if message was sent to more
Hi,
Order of addresses is changed each time a relaying fails. You can use that to distinguish which one failed and remove it.
Regards,
Damba
Re: SMTP relay in case if message was sent to more
I just checked - order of addresses is not changes in Relay.MailTo property.
More than will it be optimal to try to relay whole message again?
Re: SMTP relay in case if message was sent to more
Hi,
Yes. However, if it failed once, it's probably going to fail again. In that case, make sure that you set RetryCount property so that you make sure that realaying isn't done indefinitely.
regards,
Damba