Hi all,
I've recently transferred an ASP site from one host to another for a designer's client. the problem is i know no ASP whatsoever & with my php background i've been trying to find my way through the code.
the new site is being held on fasthosts

the original contact form didn't work on the new server so tonight i've been trawling through fasthosts documentation & their code examples to try & get something working (even just a hello world email to my inbox would be nice)
we've left the MX records as they were because their email is running through a 3rd party's mail servers & the client wants to keep that as-is.
i've tried the code from their example which fails with a 500 error at the JMail.Execute phase (plenty of commenting out code until it stops breaking then re-adding line by line until it re-breaks has diagnosed that). I'm guessing that's because the outgoing server is set to smtp.domain.co.uk & obviously that address isn't on the fasthosts cluster (as the mx records point elsewhere). i just need to get this working so i can actually populate it with the form submission!
<%
dim JMail, intComp, strReferer, strServer, strClientIP, strServerIP, blnSpam
Set JMail = Server.CreateObject("JMail.SMTPMail")
strReferer = request.servervariables("HTTP_REFERER")
strServer = Replace(request.servervariables("SERVER_NAME"),"www.","")
strClientIP = request.servervariables("REMOTE_ADDR")
strServerIP = request.servervariables("LOCAL_ADDR")
intComp = inStr(strReferer, strServer)
If intComp > 0 Then
blnSpam = False
Else
' Spam Attempt Block
blnSpam = True
End If
JMail.ServerAddress = "smtp." & strServer & ":25"
JMail.Sender = "website@" & strServer
JMail.Subject = "JMail Example" & " Sent @ " & now()
JMail.AddRecipient "my.email@mydomain.net"
JMail.Body = "This test mail sent from: " & strServerIP & " using the JMail component on the server."
JMail.Priority = 3
JMail.AddHeader "Originating-IP", strClientIP
If NOT blnSpam Then
JMail.Execute
strResult = "Mail Sent."
Else
strResult = "Mail Not Sent."
End If
set jmail=nothing
%>
the site's original sendmail code is here, but it just says "message could not be sent"
<%
'----function that removes html tags----------
Function RemoveHTML( strText )
Dim RegEx
Set RegEx = New RegExp
RegEx.Pattern = "<[^>]*>"
RegEx.Global = True
RemoveHTML = RegEx.Replace(strText, "")
End Function
'---------------------------------------------
'------defining script vars-------------------
Dim mailObj, mailCfg, myBody, fld, subj, mail_from, mail_to, smtp_server, smtp_port, plain_text
Dim RegEx
set RegEx = New RegExp
'--------------------------------------------
'----Settings-----------
subj = "Web Site Information Request"
mail_from = "website@domain.com"
mail_to = "my.email@mydomain.net"
smtp_server = "localhost"
smtp_port = 25
plain_text = "false"
'------getting data sent by site (filtering configuration data)------------
For Each fld in Request.Form
If Request.Form(fld) <> "" and _
fld <> "mail_to" and _
fld <> "smtp_server" and _
fld <> "smtp_port" and _
fld <> "plain_text" and _
fld <> "mail_from" and _
fld <> "mail_subject" Then
myBody = myBody & vbCRLF & " <b>" & fld & "</b> :<br/> " & Trim(Request.Form(fld)) & "<br/>"
End If
Next
'---------------------------------------------------------------------------
'----------setting conf data------------------------------------------------
On Error Resume Next
Set myMail = CreateObject("CDO.Message")
myMail.Subject = subj
myMail.From =mail_from
myMail.To = mail_to
'--------if plain text is set to true removing html---------------------------------------
if plain_text = "true" then
myMail.TextBody = RemoveHTML(myBody)
'-------otherwise composing message body--------------------------------------------------
else myMail.HTMLBody = "<html><body>" & myBody & "</body></html>"
end if
'----------setting configuration params for smtp----------------------------------------------------------------------------------
myMail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 1
myMail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = smtp_server
myMail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = smtp_port
myMail.Configuration.Fields.Update
'---------------------------------------------------------------------------------------------------------------------------------
myMail.Send '---------------sending message
If Err = 0 Then
Response.Write("The message has been sent, thank you") 'if there the message is sent return 1 to flash
'Response.Redirect "success.asp"
Else
Response.Write("Message could not be sent") 'otherwise return 0
End If
%>
the fasthosts documentation also says you can use CDO in ASP but the JMail approach is preferred
all these criteria are satisfied, the email is sent from
website@domain.com (for which i have also set up a mailbox just in case they check the existence of the mailbox itself rather than just the domain living on their server)
Fasthosts redirects all web based mail to an SMTP Filter System.
Emails must have either a valid "from" or "to" address which is a
mailbox hosted with Fasthosts. Any email that does not fulfil this
criterion will not be delivered. If you are sending email to a customer
who has given you his email address, you need to use the domain
name of your website.
• Fasthosts' SMTP Filter System rate limits outgoing mail from any
domain, to prevent bulk emailing. Our limits are set to allow normal
form-based email activity to pass unhindered, but stop any
persistent attempt to send bulk mail.
• The SMTP Filter System will prevent mass emailing (spam).
All attempts to send bulk emails are logged and may result in the
unfortunate suspension of your website, in accordance with our
misuse policies.
any help would be fantastic, because i'm at a bit of a loss with this! for starters, is there any kind of error reporting i can turn on like with php?
cheers
