I read much about sending mail messages with SMTPSecureSocket in web apps. Most solutions are using classes or complex mechanisms… for a contact form I want to use simpler approach by putting anything into the send button’s action event:
Dim em As New EmailMessage
(…)
Dim sss As New SMTPSecureSocket
sss.Address = smtp.colporana.com
sss.Secure = true
sss.ConnectionType = SMTPSecureSocket.TLSv12
sss.SMTPConnectionMode = SMTPSecureSocket.ModeSSLTLS
sss.Port = 25
sss.UserName = “xxx”
sss.Password = “xxx”
sss.Messages.Append(em)
sss.SendMail()
If SocketSendMail.LastErrorCode <> 0 AND SocketSendMail.LastErrorCode <> 102 Then WError.Show
(…)
As SMTP account I use the one of the server where the web app runs on (no Gmail or third party services).
Is this working the way I intend or are there any glitches or issues that could raising up when not using a separate class?
@Tim Hare : Yes, the port is correct; I’m not the server guy, so can’t say why that port was chosen. But I think that it has to do with some (outdated) server-sided tools. At least, it works.
In my experience, never assume so if it is not explicitly mentioned in the LR. Since the socket is asynchronous, it will not hold the event until finished anyway.