Foros del Web » Programación para mayores de 30 ;) » Programación General »

como programar servidor smtp en vb

Estas en el tema de como programar servidor smtp en vb en el foro de Programación General en Foros del Web. llevo semanas buscando un codigo que me sirva de ejemplo para programar un sencillo servidor smtp.estaria agradecido si alguien me pasa un codigo que me ...
  #1 (permalink)  
Antiguo 28/08/2003, 08:19
 
Fecha de Ingreso: agosto-2003
Ubicación: Sevilla
Mensajes: 2
Antigüedad: 20 años, 8 meses
Puntos: 0
como programar servidor smtp en vb

llevo semanas buscando un codigo que me sirva de ejemplo para programar un sencillo servidor smtp.estaria agradecido si alguien me pasa un codigo que me pueda ser util.gracias!
  #2 (permalink)  
Antiguo 28/08/2003, 16:19
Avatar de Javierillo  
Fecha de Ingreso: enero-2002
Ubicación: Barcelona
Mensajes: 695
Antigüedad: 22 años, 3 meses
Puntos: 0
Dim Response As String, Reply As Integer, DateNow As String
Dim first As String, Second As String, Third As String
Dim Fourth As String, Fifth As String, Sixth As String
Dim Seventh As String, Eighth As String
Dim Start As Single, Tmr As Single



Sub SendEmail(MailServerName As String, FromName As String, FromEmailAddress As String, ToName As String, ToEmailAddress As String, EmailSubject As String, EmailBodyOfMessage As String)

Winsock1.LocalPort = 0 ' Must set local port to 0 (Zero) or you can only send 1 e-mail pre program start

If Winsock1.State = sckClosed Then ' Check to see if socet is closed
DateNow = Format(Date, "Ddd") & ", " & Format(Date, "dd Mmm YYYY") & " " & Format(Time, "hh:mm:ss") & "" & " -0600"
first = "mail from:" + Chr(32) + FromEmailAddress + vbCrLf ' Get who's sending E-Mail address
Second = "rcpt to:" + Chr(32) + ToEmailAddress + vbCrLf ' Get who mail is going to
Third = "Date:" + Chr(32) + DateNow + vbCrLf ' Date when being sent
Fourth = "From:" + Chr(32) + FromName + vbCrLf ' Who's Sending
Fifth = "To:" + Chr(32) + ToNametxt + vbCrLf ' Who it going to
Sixth = "Subject:" + Chr(32) + EmailSubject + vbCrLf ' Subject of E-Mail
Seventh = EmailBodyOfMessage + vbCrLf ' E-mail message body
Ninth = "X-Mailer: EBT Reporter v 2.x" + vbCrLf ' What program sent the e-mail, customize this
Eighth = Fourth + Third + Ninth + Fifth + Sixth ' Combine for proper SMTP sending

Winsock1.Protocol = sckTCPProtocol ' Set protocol for sending
Winsock1.RemoteHost = MailServerName ' Set the server address
Winsock1.RemotePort = 25 ' Set the SMTP Port
Winsock1.Connect ' Start connection

WaitFor ("220")



Winsock1.SendData ("HELO worldcomputers.com" + vbCrLf)

WaitFor ("250")



Winsock1.SendData (first)



WaitFor ("250")

Winsock1.SendData (Second)

WaitFor ("250")

Winsock1.SendData ("data" + vbCrLf)

WaitFor ("354")


Winsock1.SendData (Eighth + vbCrLf)
Winsock1.SendData (Seventh + vbCrLf)
Winsock1.SendData ("." + vbCrLf)

WaitFor ("250")

Winsock1.SendData ("quit" + vbCrLf)



WaitFor ("221")

Winsock1.Close
Else
MsgBox (Str(Winsock1.State))
End If

End Sub
Sub WaitFor(ResponseCode As String)
Start = Timer ' Time event so won't get stuck in loop
While Len(Response) = 0
Tmr = Start - Timer
DoEvents ' Let System keep checking for incoming response **IMPORTANT**
If Tmr > 50 Then ' Time in seconds to wait
MsgBox "SMTP service error, timed out while waiting for response", 64, MsgTitle
Exit Sub
End If
Wend
While Left(Response, 3) <> ResponseCode
DoEvents
If Tmr > 50 Then
MsgBox "SMTP service error, impromper response code. Code should have been: " + ResponseCode + " Code recieved: " + Response, 64, MsgTitle
Exit Sub
End If
Wend
Response = "" ' Sent response code to blank **IMPORTANT**
End Sub


Private Sub Command1_Click()
SendEmail txtEmailServer.Text, txtFromName.Text, txtFromEmailAddress.Text, txtToEmailAddress.Text, txtToEmailAddress.Text, txtEmailSubject.Text, txtEmailBodyOfMessage.Text
'MsgBox ("Mail Sent")

Beep

Close
End Sub




Private Sub Winsock1_DataArrival(ByVal bytesTotal As Long)

Winsock1.GetData Response ' Check for incoming response *IMPORTANT*

End Sub



Has de crear 7 text box,uno llamados txtFromEmailAddress txtToEmailAddress txtEmailSubject txtEmailServer txtEmailBodyOfMessage txtFromName txtEmailSubject
Y ponerle el winsock.........
En email server puedes poner mail.menta.net a mi siempre me los envia con ese
Suerte
__________________
NO CLIKES AQUI!!!
  #3 (permalink)  
Antiguo 28/08/2003, 18:41
 
Fecha de Ingreso: agosto-2003
Ubicación: Sevilla
Mensajes: 2
Antigüedad: 20 años, 8 meses
Puntos: 0
gracias por tu codigo,pero no puedo arriesgarme a añadirle a mi prollecto un servidor externo que puede fallar en cualquier momento.Necesito programar mi propio servidor.De todas maneras tu codigo me puede ser muy util.Gracias de nuevo.
  #4 (permalink)  
Antiguo 29/08/2003, 05:53
Avatar de Javierillo  
Fecha de Ingreso: enero-2002
Ubicación: Barcelona
Mensajes: 695
Antigüedad: 22 años, 3 meses
Puntos: 0
de nada hombre,para eso estamos
__________________
NO CLIKES AQUI!!!
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 04:31.