Failure sending mail
am 30.10.2007 09:53:09 von danny
Hi all,
Trying to send mail with System.Net.SmtpClient, using very simple code
just for testing:
SmtpClient smtp = new SmtpClient("mail.server.com", 25);
smtp.Credentials = new
System.Net.NetworkCredential("user", "password");
try
{
smtp.Send("sender@server.com",
"recipient@server.com",
"Subject",
"Body");
MessageBox.Show("Mail Sent!");
}
catch (Exception ex)
{
txtErrorMsg.Text = ex.ToString();
}
BTW, the mail.server.com is not mine, it's an ISP mail server.
On my local machine, this code works fine and actualy sending the
mail.
BUT, on my remote server the same code produces the exceptions as
follows:
System.Net.Mail.SmtpException: Failure sending mail. --->
System.Net.WebException: Unable to connect to the remote server --->
System.Net.Sockets.SocketException: No connection could be made
because the target machine actively refused it
at System.Net.Sockets.Socket.DoConnect(EndPoint endPointSnapshot,
SocketAddress socketAddress)
at System.Net.Sockets.Socket.InternalConnect(EndPoint remoteEP)
at System.Net.ServicePoint.ConnectSocketInternal(Boolean
connectFailure, Socket s4, Socket s6, Socket& socket, IPAddress&
address, ConnectSocketState state, IAsyncResult asyncResult, Int32
timeout, 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, Int32 timeout)
at System.Net.PooledStream.Activate(Object owningObject, Boolean
async, Int32 timeout, 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(String host, Int32
port)
at System.Net.Mail.SmtpTransport.GetConnection(String host, Int32
port)
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 System.Net.Mail.SmtpClient.Send(String from, String recipients,
String subject, String body)
at TestWindows.FrmSendSMTPMail.btnSend_Click(Object sender,
EventArgs e)
Weird stuff...
My remote server has Windows Server 2003.
So, am I missing something?
Thanks in advance,
Danny
Re: Failure sending mail
am 30.10.2007 14:52:33 von cshNOSPAMPLEASE
Danny schreef:
> Hi all,
>
> Trying to send mail with System.Net.SmtpClient, using very simple code
> just for testing:
> SmtpClient smtp = new SmtpClient("mail.server.com", 25);
> smtp.Credentials = new
> System.Net.NetworkCredential("user", "password");
>
> try
> {
> smtp.Send("sender@server.com",
> "recipient@server.com",
> "Subject",
> "Body");
>
> MessageBox.Show("Mail Sent!");
> }
> catch (Exception ex)
> {
> txtErrorMsg.Text = ex.ToString();
> }
>
> BTW, the mail.server.com is not mine, it's an ISP mail server.
>
> On my local machine, this code works fine and actualy sending the
> mail.
>
> BUT, on my remote server the same code produces the exceptions as
> follows:
>
> System.Net.Mail.SmtpException: Failure sending mail. --->
> System.Net.WebException: Unable to connect to the remote server --->
> System.Net.Sockets.SocketException: No connection could be made
> because the target machine actively refused it
Is the remote server connected to the same ISP? If not, your ISP may
simply be denying connections to the mailserver other than it's own domain.
--
Rinze van Huizen
C-Services Holland b.v
Re: Failure sending mail
am 30.10.2007 16:57:01 von sloan
Get the downloadable code from here:
http://sholliday.spaces.live.com/Blog/cns!A68482B9628A842A!1 38.entry
and look at the different authentication modes.
"Danny" wrote in message
news:1193734389.270161.213920@o38g2000hse.googlegroups.com.. .
> Hi all,
>
> Trying to send mail with System.Net.SmtpClient, using very simple code
> just for testing:
> SmtpClient smtp = new SmtpClient("mail.server.com", 25);
> smtp.Credentials = new
> System.Net.NetworkCredential("user", "password");
>
> try
> {
> smtp.Send("sender@server.com",
> "recipient@server.com",
> "Subject",
> "Body");
>
> MessageBox.Show("Mail Sent!");
> }
> catch (Exception ex)
> {
> txtErrorMsg.Text = ex.ToString();
> }
>
> BTW, the mail.server.com is not mine, it's an ISP mail server.
>
> On my local machine, this code works fine and actualy sending the
> mail.
>
> BUT, on my remote server the same code produces the exceptions as
> follows:
>
> System.Net.Mail.SmtpException: Failure sending mail. --->
> System.Net.WebException: Unable to connect to the remote server --->
> System.Net.Sockets.SocketException: No connection could be made
> because the target machine actively refused it
> at System.Net.Sockets.Socket.DoConnect(EndPoint endPointSnapshot,
> SocketAddress socketAddress)
> at System.Net.Sockets.Socket.InternalConnect(EndPoint remoteEP)
> at System.Net.ServicePoint.ConnectSocketInternal(Boolean
> connectFailure, Socket s4, Socket s6, Socket& socket, IPAddress&
> address, ConnectSocketState state, IAsyncResult asyncResult, Int32
> timeout, 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, Int32 timeout)
> at System.Net.PooledStream.Activate(Object owningObject, Boolean
> async, Int32 timeout, 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(String host, Int32
> port)
> at System.Net.Mail.SmtpTransport.GetConnection(String host, Int32
> port)
> 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 System.Net.Mail.SmtpClient.Send(String from, String recipients,
> String subject, String body)
> at TestWindows.FrmSendSMTPMail.btnSend_Click(Object sender,
> EventArgs e)
>
> Weird stuff...
> My remote server has Windows Server 2003.
>
> So, am I missing something?
>
> Thanks in advance,
> Danny
>