Sending email from our web app

Discussion in 'Email' started by wellpointvi, Oct 11, 2010.

Thread Status:
Threads that have been inactive for 5 years or longer are closed to further replies. Please start a new thread.
  1. We have been sending email from our web apps hosted elsewhere, but the same code doesn't work on our site which is hosted here by Discount ASP.NET.

    The code says email was sent successfully but in reality, nothing is sent.

    Is there a step-by-step sample on how to send email from within our web app here at Discount ASP.NET? We are using C# with ASP.NET 3.5 and the volume is minimal (e.g. one or two emails a day; not mass email).
     
  2. dmitri

    dmitri DiscountASP.NET Staff

    Please feel free to modify and use the sample code from this KB article. When you are sending messages through a web application, please specify "localhost" as the SMTP server with user name and password left blank to send messages through the local mail relay.
     
  3. Before deploying this code to your server, I tried it on my machine (within Visual Studio 2008) and got this error:

    Email Error: 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 127.0.0.1:25 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 MembershipAdmin_Request2CreateUser.ButtonSubmit_Click(Object sender, EventArgs e) in c:\Users\Ben\Documents\Pointer16T3\MembershipAdmin\Request2CreateUser.aspx.cs:line 58
     
  4. That will because you don't have an SMTP server on 127.0.0.1:25 on your local machine; or at least you don't have one with port #25 open.
     
  5. Thanks. I deployed it to your server and it worked.
     
  6. Would like to bump this thread up. I followed that same pattern of SmtpClient object usage outlined in the sample code KB link above and I am using localhost as my mail relay but no messages are being received by the destination e-mail address. I tried both an external address as well as one that comes with my discountASP plan. It does not appear that .Send throws an exception so the mail is probably getting backed up somewhere. Please note that I "just" become a new customer... less than an hour ago. Is there an initial setup step that hasn't been completed yet?

    Thanks
     
  7. If you're having that problem, you could ask support to test localhost. Make sure you let them know exactly what settings you're using for SMTP.
     
Thread Status:
Threads that have been inactive for 5 years or longer are closed to further replies. Please start a new thread.

Share This Page