Hi i am using the hosting from goodaddy, mi aplication was made in c#, the problem is when send an email, this is my code
public ResponseDto sendEmail(EmailDto emailDto) {
try
{
MailMessage message = new MailMessage();
SmtpClient client = new SmtpClient();
message.From = new MailAddress("mail@gmail.com");
message.Subject = "have a new mail";
message.Body = "info: \n "
+ "name: " + emailDto.Name
+ "\mail: "+ emailDto.Email + "\nMessage: " +
emailDto.Message;
message.To.Add("mail@hotmail.com");
client.EnableSsl = true;
client.UseDefaultCredentials = false;
client.Port = 587;
client.Host = "smtp.gmail.com";
client.Credentials = new System.Net.NetworkCredential("mail@gmail.com", "(password");
client.Send(message);
}
catch (Exception e) {
return new ResponseDto
{
message = e.ToString()
,
Success = false
};
}
return new ResponseDto
{
message = "success",
Success = true
};
}
my email that send the email is gmail, the error is the next
System.Net.Mail.SmtpException: Failure sending mail. ---> System.Net.WebException: Unable to connect to the remote server ---> System.Net.Sockets.SocketException: An attempt was made to access a socket in a way forbidden by its access permissions 74.125.199.109:587 at System.Net.Sockets.Socket.DoConnect(EndPoint endPointSnapshot, SocketAddress socketAddress) at System.Net.ServicePoint.ConnectSocketInternal(Boolean connectFailure, Socket s4, Socket s6, Socket& socket, IPAddress& address, ConnectSocketState state, IAsyncResult asyncResult, Exception& exception) --- End of inner exception stack trace --- at System.Net.ServicePoint.GetConnection(PooledStream PooledStream, Object owner, Boolean async, IPAddress& address, Socket& abortSocket, Socket& abortSocket6) at System.Net.PooledStream.Activate(Object owningObject, Boolean async, GeneralAsyncDelegate asyncCallback) at System.Net.PooledStream.Activate(Object owningObject, GeneralAsyncDelegate asyncCallback) at System.Net.ConnectionPool.GetConnection(Object owningObject, GeneralAsyncDelegate asyncCallback, Int32 creationTimeout) at System.Net.Mail.SmtpConnection.GetConnection(ServicePoint servicePoint) at System.Net.Mail.SmtpTransport.GetConnection(ServicePoint servicePoint) at System.Net.Mail.SmtpClient.GetConnection() at System.Net.Mail.SmtpClient.Send(MailMessage message) --- End of inner exception stack trace --- at System.Net.Mail.SmtpClient.Send(MailMessage message) at Core.EmailManager.sendEmail(EmailDto emailDto)
What could be the problem?