0

I have a form on an asp.net Website that is hosted over at tedata (hosting company) that users can fill out and send to our company. I am currently testing it using a Gmail account. the email send fine from my localhost, but when I publish it to the web server the mail does not send and there is no error message, can any one help me, here is my code:

Public Sub SendMail()
        Dim fromAddress = "eisegypt2017@gmail.com"
        Dim toAddress = "toAddress"
        Dim fromPassword As String = "fromPassword"

        Dim subject As String = "Mail"
        Dim body As String = "From: " + yourname.Value + vbCrLf + vbCrLf
        body = body + "Company: " + yourcompany.Value + vbCrLf + vbCrLf
        body = body + "Email: " + youremail.Value + vbCrLf + vbCrLf
        body = body + "Phone: " + yourphone.Value + vbCrLf + vbCrLf
        body += "Subject: " + subject + vbCrLf + vbCrLf
        body += "Message: " + yourmessage.Value + vbCrLf

        ' smtp settings
        Dim smtp = New System.Net.Mail.SmtpClient()
        Dim omail As New System.Net.Mail.MailMessage
        smtp.Host = "smtp.gmail.com"
        smtp.Port = 587
        smtp.EnableSsl = True
        smtp.DeliveryMethod = System.Net.Mail.SmtpDeliveryMethod.Network
        smtp.Credentials = New System.Net.NetworkCredential(fromAddress, fromPassword)
        smtp.Timeout = 20000

        ' Passing values to smtp object
         smtp.Send(fromAddress, toAddress, subject, body)

    End Sub
pkamil
  • 1
  • 1
  • check your app server's log files. Most likely a security or other network issue. login to the app server and see if you can telnet from there to the mail system. – OldProgrammer Dec 26 '16 at 20:39
  • may be this can help you http://stackoverflow.com/a/32336/771579 – Orlando Herrera Dec 26 '16 at 21:04
  • In the `smtp.Send` method you should be passing `omail` object and you are not. You declare a new instance and never use it; this is what you would use to set your body, subject etc... Also worth mentioning you want `smtp.UseDefaultCredentials = False` when you are supplying the username and password... – Trevor Dec 27 '16 at 05:44
  • i am using plesk panel to log to server how can i telnet from there to the mail system – pkamil Dec 28 '16 at 21:59

0 Answers0