Problema no envio de e-mail!

.NET

25/02/2008

[b:c5ef67e6b2]Olá! Estou com um problema na parte de contato de um site q estou fazendo... O código é o seguinte :

using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Net.Mail;

public partial class contato : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        statusLabel.Text = "TesteLabel!";
    }
    protected void enviarButton_Click(object sender, EventArgs e)
    {
        MailMessage mail = new MailMessage(emailTextBox.Text, "hnkarla@gmail.com", "Contato - Rodotruck", mensagemTextBox.Text);
        SmtpClient client = new SmtpClient("localhost");

        try
        {
            client.Send(mail);
            statusLabel.Text = "Mensagem Enviada com Sucesso!";
            Response.Write("Msg Enviada");
        }

        catch (Exception erro)
        {
            statusLabel.Text = "Falha ao enviar mensagem!";
            Response.Write(erro);
   
        }

        finally {
            mail.Dispose();
        }
              
    }

 
}




Tá dando mensgem enviada, mas não recebo nada! Já configurei o IIS, acho q está certo.. pq antes já caia na excpetion ali ´System.Net.Mail.SmtpFailedRecipientException´, mas ai mexei na configuraçao e agora dá msg enviada, mas n envia, se vcs puderem me ajudar eu agradeço =]

Obrigada!

[/b:c5ef67e6b2]


Hnkarla

Hnkarla

Curtidas 0

Respostas

Massuda

Massuda

25/02/2008

Seu servidor SMTP requer login/autenticação?


GOSTEI 0
Hnkarla

Hnkarla

25/02/2008

Então é o servidor local esse...localhost...
Onde posso saber se ele requer autorização?


GOSTEI 0
Hnkarla

Hnkarla

25/02/2008

Coloquei no codigo pra imprimir o erro...
e olha o qq deu

System.Net.Mail.SmtpException: Falha ao enviar email. ---> System.Net.WebException: Impossível conectar-se ao servidor remoto ---> System.Net.Sockets.SocketException: Nenhuma conexão pôde ser feita porque a máquina de destino as recusou ativamente em System.Net.Sockets.Socket.DoConnect(EndPoint endPointSnapshot, SocketAddress socketAddress) em System.Net.Sockets.Socket.InternalConnect(EndPoint remoteEP) em System.Net.ServicePoint.ConnectSocketInternal(Boolean connectFailure, Socket s4, Socket s6, Socket& socket, IPAddress& address, ConnectSocketState state, IAsyncResult asyncResult, Int32 timeout, Exception& exception) --- Fim do rastreamento de pilha de exceções internas --- em System.Net.ServicePoint.GetConnection(PooledStream PooledStream, Object owner, Boolean async, IPAddress& address, Socket& abortSocket, Socket& abortSocket6, Int32 timeout) em System.Net.PooledStream.Activate(Object owningObject, Boolean async, Int32 timeout, GeneralAsyncDelegate asyncCallback) em System.Net.PooledStream.Activate(Object owningObject, GeneralAsyncDelegate asyncCallback) em System.Net.ConnectionPool.GetConnection(Object owningObject, GeneralAsyncDelegate asyncCallback, Int32 creationTimeout) em System.Net.Mail.SmtpConnection.GetConnection(String host, Int32 port) em System.Net.Mail.SmtpTransport.GetConnection(String host, Int32 port) em System.Net.Mail.SmtpClient.GetConnection() em System.Net.Mail.SmtpClient.Send(MailMessage message) --- Fim do rastreamento de pilha 


me ajudem!!


GOSTEI 0
Hnkarla

Hnkarla

25/02/2008

de exceções internas --- em System.Net.Mail.SmtpClient.Send(MailMessage message) em contato.enviarButton_Click(Object sender, EventArgs e) na c:\Web\\contato.aspx.cs:linha 26
GOSTEI 0
Massuda

Massuda

25/02/2008

Então é o servidor local esse...localhost...
localhost significa que é a mesma máquina onde está rodando o servidor web.

Se você estiver testando na sua máquina, além do servidor web (HTTP), você precisa estar rodando também um servidor SMTP.

Onde posso saber se ele requer autorização?
Verifique com o administrador do servidor que você estiver usando.

Coloquei no codigo pra imprimir o erro...
O erro indica que não está conseguindo comunicar com o servidor SMTP; entre muitas coisas, provalvemente o servidor SMTP não está rodando ou tem um firewall impedindo a comunicação.


GOSTEI 0
POSTAR