Easy Question (Hopefull) MailClient from asp.net website

Discussion regarding the Standard version.
Post Reply
Posts: 5
Joined: Wed Jan 17, 2018 2:50 pm

Easy Question (Hopefull) MailClient from asp.net website

Post by mkucera » Wed Jan 17, 2018 3:08 pm

I have MailEnable installed on my server and have verified that i can receive email at the domains that i've setup. However now, i'd like to be able to send email from my ASP.NET website via MailEnable. I am using the standard (free) edition. thanks in advance for your help.

On the server i setup Relay permissions.
Allow Mail Relay -> Check
Allow relay for authenticated senders -> Check
Authentication Method -> Authenticate against the following username/password (username and password entered)
Allow relay for privileged IP ranges -> Check (server IP address added to list)

On my server, in the config i have entered:

<smtp from="mail@MYDOMAIN.COM">
<network defaultCredentials="false" host="MYDOMAIN.COM" port="25" password="PASSWORD" userName="USERNAME"/>

the mail@ is a valid mailbox
the host is one of the domains that i have setup in mailenable
the username and password are what i entered above for the authentication method popup.

in my application code i am trying this:

using (SmtpClient client = new SmtpClient())
MailAddress maFrom = new MailAddress("From Name <mail@MYDOMAIN.com>");
MailAddress maTo = new MailAddress("Mark <MY PERSONAL EMAIL ADDRESS>");
MailMessage message = new MailMessage(maFrom, maTo);
message.Subject = "Testing Email Setup";
message.Body = "<p><b>This is the message Body</b></p>";
message.IsBodyHtml = true;
message.BodyEncoding = Encoding.UTF8;
message.SubjectEncoding = Encoding.UTF8;


The error i get is this:

System.Net.Mail.SmtpException: Failure sending mail. ---> System.Net.WebException: Unable to connect to the remote server ---> System.Net.Sockets.SocketException: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond 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 Default2.btnSend_Click(Object sender, EventArgs e) in d:\home\site\wwwroot\Default2.aspx.cs:line 41

The only other item of note to mention is that the website is running on Azure, and MailEnable is running on an Azure VM. I believe i have the necessary ports open for the VM in Azure, as i mentioned i can receive mail.

what am i missing? i'm sure it's something simple.

Site Admin
Posts: 826
Joined: Mon Jun 10, 2002 6:31 pm
Location: Melbourne, Victoria, Australia

Re: Easy Question (Hopefull) MailClient from asp.net website

Post by Admin » Fri Jan 19, 2018 11:10 pm

Is the website on the same server as MailEnable? Try using the following (i.e. changing the domain to localhost):

Code: Select all

<network defaultCredentials="false" host="localhost" port="25" password="PASSWORD" userName="USERNAME"/>
Since the error is that is cannot connect, possibly it is unable to use the IP returned by using the domain you have.

Post Reply