简体   繁体   中英

My asp formail not working

I have wasted nearly 2 days trying to figure out. I use gmail apps paid email for my domain name. From the website i'm trying to send a small contact form, but somehow it's not working and i['m not getting any emails. Below is my script

 <%

dim sEmailContent

sEmailContent = sEmailContent & "Full Name : " & Request.Form("full_name") & vbCrLf
sEmailContent = sEmailContent & "Phone : " & Request.Form("phone") & vbCrLf
sEmailContent = sEmailContent & "Email : "& Request.Form("email") & vbCrLf
sEmailContent = sEmailContent & "Message : "& Request.Form("message")


'Response.Write(sEmailContent)

call send_email(Request.Form("email"),sEmailContent)

function send_email(sToEmail,sEmailBody)
on error resume next
    Dim ObjSendMail
    Set ObjSendMail = CreateObject("CDO.Message")

    'Configuration for remote SMTP server

    'Network Send    
    ObjSendMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2

    'Name of SMTP server
    ObjSendMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserver") ="smtp.gmail.com"


    'SMTP port
    ObjSendMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserverport") =  587


    'MaxESP SMTP servers require authentication

    'Basic Authentication
    ObjSendMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1


    'SMTP username as configured in the control panel
    ObjSendMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusername") ="bla@domain.com"

    'SMTP user password as configured in the control panel
    ObjSendMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendpassword") ="blablabla"






    ObjSendMail.Configuration.Fields.Update


    'Configuration for email message

    'Email To address
    ObjSendMail.To = "bla@domain.com"
    'Email Subject
    ObjSendMail.Subject = "Contact Us Query"

    'Email From address
    ObjSendMail.From = "bla@domain.com"

    'Email Body
    ObjSendMail.TextBody = sEmailBody

    ObjSendMail.Send

    Set ObjSendMail = Nothing

    response.Redirect("contact-us.html")
if err.number <> 0 then
    Response.Redirect("contact-us.html")
end if
on error goto 0 
end function
 %> 

Please tell me what am I doing wrong? Thanks

Could be a number of things.

  • Hosting could be blocking this. Might be worth opening a ticket with them so that they can trace what happens
  • Are you definitely sure that you haven't received it. Check spam boxes locally and on mail server. Happened to me before.
  • Using the same email address to send from and to can cause problems. Try varying email addresses and maybe even a fake from address to avoid any dns issues

Did you get an ASP error?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM