Help Mailer code change for new server ?

Discussion in 'General Web Coding' started by jnw, Oct 19, 2006.

  1. jnw

    jnw Guest

    I have just changed to a new server and the asp on the site works fine but the mail part won't run(worked fine on the old server). I have spoken to Fasthosts and they tell me they support jmail, cdonts and cdo. I guess it's the mail sender that is not supported? The code I have is as follows. I am hopeing that it would be easier to adapt the code rather than write a new script which would be a problem for me, given my abilities with asp.

    <%
    dim firstname, email, can_we_help, Tmonth, Tday, Tyear, transfers
    dim adults, children, accomodation, nights, referred_by, ref_other, Mailer

    firstname = request.form("firstname")
    email = request.form("email")
    can_we_help = request.form("can_we_help")
    Tmonth = request.form("Tmonth")
    Tday = request.form("Tday")
    Tyear = request.form("Tyear")
    transfers = request.form("transfers")
    adults = request.form("adults")
    children = request.form("children")
    accomodation = request.form("accomodation")
    nights = request.form("nights")
    referred_by = request.form("referred_by")
    ref_other = request.form("ref_other")

    ' Creating the mail component's Instance.
    Set Mailer = Server.CreateObject("Persits.MailSender")

    'Saving sender's information in mail object properties to send it to Server.
    Mailer.FromName = firstname ' Mail sent from name.
    Mailer.From = email
    Mailer.Host = "localhost" ' Mail server Address.
    Mailer.AddAddress "enquiries@mydomain.co.uk"
    'Mailer.AddBCC "test@test.co.uk"
    Mailer.Subject = "Property Enquiry"

    ' Formating the information got from above declared variables in order to send it to specific address.
    Mailer.Body = "mycompany" & vbcrlf & vbcrlf+_

    "==================================================" & vbcrlf & vbcrlf+_
    "DETAILS" & vbcrlf & vbcrlf+_
    " Name: " & firstname & vbcrlf+_
    " How can we help? " & can_we_help & vbcrlf+_
    " Visiting Dates: " & Tmonth & "' " & Tday & ", " & Tyear & vbcrlf

    if transfers = "yes" then
    Mailer.Body = Mailer.Body & " Airport Transfer requires: " & transfers & "for " & adults & " & " & children & " children" & vbcrlf
    else
    Mailer.Body = Mailer.Body & " Airport Transfer requires: " & transfers & vbcrlf
    end if

    if transfers = "yes" then
    Mailer.Body = Mailer.Body & " Accomodation requires: " & accomodation & " for " & nights & " nights" & vbcrlf
    else
    Mailer.Body = Mailer.Body & " Accomodation requires: " & accomodation & vbcrlf
    end if

    Mailer.Body = Mailer.Body & " Referred By: " & referred_by & vbcrlf
    Mailer.Body = Mailer.Body & " Other Referal: " & ref_other & vbcrlf


    ' Send the mail in the above given format
    On Error Resume Next ' If in case any error occurs then don't show the error and contiinue displaying page.
    Mailer.Send ' Mail sent command.

    If Err <> 0 Then
    error_message1= "An error occurred: " & Err.Description
    End If

    Mailer.ResetAll

    Mailer.FromName = "My Company" ' Mail sent from name.
    Mailer.From = "enquiries@mycompany.co.uk"
    Mailer.Host = "mail.mycompany.co.uk" ' Mail server Address.
    Mailer.AddAddress email
    Mailer.Subject = "my company Enquiry Confirmation"
    Mailer.Body = "Thank you for your enquiry, we will contact you soon."

    ' Send the mail in the above given format
    On Error Resume Next ' If in case any error occurs then don't show the error and contiinue displaying page.
    Mailer.Send ' Mail sent command.

    If Err <> 0 Then
    error_message2 = "An error occurred: " & Err.Description
    End If

    set Mailer = nothing
    %>

    Thanks
  2. ChrisLKirby

    ChrisLKirby Guppy

    please private message me and i can assist you with this.
  3. ChrisLKirby

    ChrisLKirby Guppy

    also, when you post a script, please try to post the line numbers as well as the error you are getting. if you turn off friendly error messages in Internet Explorer you will can an error number line. please include that in your post also.

Share This Page

JodoHost - 26,000 hosting end-users in 100 countries
Plesk Web Hosting
VPS Hosting
H-Sphere Web Hosting
Other Services