' need SMTP server to route message thru, 25 (SMTP)
Winsock1.Connect "smtp.freeserve.net", 25
The email server isn't working. Any ideas on what i can put for connecting to a server to send an email, in visual basic?
It may not run on port 25. If it's using TLS or some other form of secure stream, you'll need to connect to the proper port.
It is 25, i have been reading tutorials on it. Its sent via SMTP. Any ideas people? Or could somebody point me in another direction for what to connect to, to send an email? Thanks in advance!
That address works fine... just tested and it sent me:
220 cmailm1.svr.pol.co.uk ESMTP Exim 4.41 Fri, 08 Jul 2005 21:57:25 +0100
some more problems, connects and everything but i dont receive email.
heres my code
sFrom$ = Me.frmemail.Text
sTo$ = "<my email here>"
sSubject$ = "testy"
sMessage$ ="this is a test"
' need SMTP server to route message thru, 25 (SMTP)
Winsock1.Connect "smtp.freeserve.net", 25
Do While Winsock1.State <> sckConnected: DoEvents: Loop
sendMsg "HELO " & "Peaches"
sendMsg "MAIL FROM: <" & sFrom & ">"
sendMsg "RCPT TO: <" & sTo & ">"
sendMsg "DATA"
m$ = m$ + "From: <" + sFrom + ">" + vbCrLf
m$ = m$ + "To: <" + sTo + ">" + vbCrLf
m$ = m$ + "Subject: " + sSubject$ + vbCrLf
m$ = m$ + "Date: " + Format$(Now, "h:mm:ss") + vbCrLf
m$ = m$ + "MIME-Version: 1.0" + vbCrLf
m$ = m$ + "Content-Type: text/plain; charset=us-ascii" + vbCrLf + vbCrLf
m$ = m$ + sMessage$ + vbCrLf + vbCrLf + "." + vbCrLf
sendMsg m$ + "QUIT"
Winsock1.Close
Uh.
sendMsg m$
sendMsg "QUIT"
Try that instead of combining them.
I'd re-write all of that coding, personally.
It's sloppy as hell.
Well it doesn't crash anymore. But still no email. Any ideas people?
I don't know much about SMTP, but is there a message you're supposed to send when you're done with DATA?
erm i just read something on winsockvb.com and it says that after you attempt to send it, the SMTP(or POP3) server replies with a number indicating what happened. perhaps you could get the number with the DataArrival sub to find out why it isnt sending?
then again im not familiar with SMTP servers.
Maybe that mail server requires authentication?
554 SMTP synchronization error
You're not allowed to send mail.
More info: http://www.networksorcery.com/enp/protocol/smtp.htm
554: Transaction failed.
Thanks for that website Rabbit. :) It helps. I will post when i get more problems :)
If you're on a Workstation- or Server-based machine with IIS and the SMTP virtual server, you can send mail through the local server via the object CDONTS.NewMail.
Im i got confused in the sloppy coding so im restarting. What is the easiest way to send an email? Thanks in advance!
Quote from: QwertyMonster on July 09, 2005, 12:07 PM
Im i got confused in the sloppy coding so im restarting. What is the easiest way to send an email? Thanks in advance!
SMTP server!
Assuming VB and that you're on a Windows NT Workstation- or Server-based system that has IIS and the SMTP Virtual Server installed, if you use the CDONTS.NewMail (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cdo/html/_denali_newmail_object_cdonts_library_.asp) object:
Dim mailObj As CDONTS.NewMail
Set mailObj = CreateObject("CDONTS.NewMail")
mailObj.To = "[email protected]"
mailObj.From = "[email protected]"
mailObj.Subject = "This is spam."
mailObj.Body = "This is a spam message from everyone who directly copied your code sample from vL."
mailObj.Send
Set mailObj = Nothing
Ah i will look into CDONTS. Thanks MyndFyre.
Just stick with telnet, it's more fun :)