I'm having problems with ASP code
Hi Everyone,
I'm having some difficult with the asp code below. I'm using it to send email from a pop-up form at http://www.fast-sites.net but it doesn't send. The mailer is SoftArtisans.SMTPMail and this is installed on my server.
I just a copy and paste when it comes to scripting but did fiddle around with it but could not get it to send.
Anyone have any idea why it won't send. I would be most appreciative if anyone could help me out.
Thanks
Gavin
<?php
'on Error Resume Next
DIM adminemail
adminemail = "[email protected]"
'--------------------------------------------
'CHECK TO SEE IF AN EMAIL WAS ENTERED
'--------------------------------------------
SUB init_check(byRef hadErrors, byRef strPage)
IF trim(Request("email")) & "" = "" THEN
hadErrors=true
END IF
END SUB
'--------------------------------------------
'CHECK IF THE EMAIL ENTERED IS A VALID EMAIL
'--------------------------------------------
SUB ChkEmail(byVal email, byRef strPage)
Dim goby, bademail
goby = 0
if Len(email) <= 5 Then
goby = 0
End If
If InStr(1, email, "@", 1) < 2 Then
goby = 1
Else
If InStr(1,email, ".", 1) < 4 Then
goby = 1
End If
End If
IF goby <> 0 THEN
email = ""
strPage = "<font face=""Arial, helvetica""><font size=""4""><b>Data Error!</b></font><br>" & vbCrLf
strPage = strPage & "<font size=""2"">Please go back enter a valid E-mail address.<br>" & vbCrLf
strPage = strPage & "<a href=""Javascript:history.go(-1)""><u>< Go Back</u></a></font></font>"
END IF
END SUB
Sub mail_it(byVal adminemail, byRef strPage)
DIM mailer, HTML
Set mailer = Server.CreateObject("SoftArtisans.SMTPMail")
mailer.RemoteHost = "mail.fast-sites.net"
mailer.FromAddress = request("email")
mailer.AddRecipient "" , adminemail
HTML = ""
HTML = HTML & "email:" & request("email") & vbCrLf
mailer.BodyText = HTML
mailer.Subject = "subscribe fastsite"
'SEND THE MAIL NOW
If mailer.SendMail then response.redirect "subscribe_cfrm.htm"
Else
strPage = "<font face=""Arial, helvetica""><font size=""4""><b>Mail Error!</b></font><br>" & vbCrLf
strPage = strPage & "<font size=""2"">Sorry your message has not been sent due to an unspecified error." & vbCrLf
strPage = strPage & "Please email <a href=""mailto:[email protected]?Subject=Contact Form"">[email protected]</a> with your contact information.</font></font>"
end if
set mailer = nothing
End Sub
'--------------------------------------------
'START THE PROCESS
'--------------------------------------------
DIM hadErrors, strPage
CALL init_check(hadErrors, strPage)
IF hadErrors=false THEN
CALL ChkEmail(request("email"),strPage)
IF strPage = "" then
CALL mail_it(adminemail, strPage)
END IF
ELSE
strPage = "<font face=""Arial, helvetica""><font size=""4""><b>Data Error!</b></font><br>" & vbCrLf
strPage = strPage & "<font size=""2"">Please go back and try again<br>" & vbCrLf
strPage = strPage & "<a href=""Javascript:history.go(-1)"">< Go Back</a></font></font>"
END IF
?>
Peter J. Boettcher posted this at 14:01 — 22nd April 2002.
They have: 812 posts
Joined: Feb 2000
What is the exact error you're getting? or are you not getting an error and its just not sending the email.
Also, you might want to include the .form or .querystring in your request("") code parts. When you don't specify which request you want (form/querystring/servervariables) it searches through all of them which can slow things a bit.
PJ | Are we there yet?
pjboettcher.com
gavin681 posted this at 19:33 — 22nd April 2002.
They have: 184 posts
Joined: May 2001
I'm just getting a blank basic error page.
Peter J. Boettcher posted this at 20:04 — 22nd April 2002.
They have: 812 posts
Joined: Feb 2000
Maybe try creating a simple script like:
DIM mailer
Set mailer = Server.CreateObject("SoftArtisans.SMTPMail")
mailer.RemoteHost = "mail.fast-sites.net"
mailer.FromAddress = "[email protected]"
mailer.AddRecipient "" , "[email protected]"
mailer.BodyText = "test"
mailer.Subject = "subscribe fastsite"
mailer.SendMail
Set mailer = nothing
Try running that by itself and see what happens. (replace the email address with yours)
PJ | Are we there yet?
pjboettcher.com
BobFather posted this at 03:12 — 3rd May 2002.
They have: 4 posts
Joined: Feb 2002
Why not Just CDONTS. CDONTS a built in messaging service in windows servers. No reason to tie up processes using a 3rd party COM.
Try this simple script.
Dim MyMail
Set MyMail = Server.CreateObject("CDONTS.NewMail")
MyMail.From = "[email protected]"
MyMail.To = "[email protected]"
MyMail.Subject = "Subject"
MyMail.BodyFormat = 1
MyMail.MailFormat = 0
MyMail.Importance = 2
MyMail.Body = "Body"
MyMail.Send
Set MyMail = Nothing
Rob
gavin681 posted this at 19:26 — 3rd May 2002.
They have: 184 posts
Joined: May 2001
thanks for the feedback everyone. I decided to use CDONTS and everything is working fine now.
Thanks again.
Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.