C# .NET - Mail Server

Asked By ravi bushan
02-Nov-08 10:41 AM
I want to send mail through coding , But in the code i have to write the SMTP server name , but I don't have the SMTP mail server .
Can I send mail without installing SMTP mail server or by Configuring the IIS on my PC , If yes then what should I have to write in the place of "SMTP server name" .
Is their any site from where can i get the SMTP server (full version) for free .

Mail Server  Mail Server

02-Nov-08 11:10 AM

Hi Ravi,

You can download SMTP server for free of cost from below sites. It will act as a local SMTP servers.

http://www.qksoft.com/qk-smtp-server/

http://www.topshareware.com/free-smtp-server/downloads/1.htm

http://www.bestsoftware4download.com/software/t-free-free-smtp-server-download-tfelcnhw.html

See http://www.eggheadcafe.com/articles/20030316.asp article which has complete code to send mails without using SMTP server or CDO.

You can also send emails without using SMTP server but using DNS lookups. See below code which sends a mails to the recepients which are not in same domain. Ofcourse there are some limitations, see  http://www.emailarchitect.net/WebApp/SMTPCOM/developers/dnslookup.asp for details.

You can also use CDO objects or MAPI sessions concept to send the email which dont required SMTP server.

private void SendEmail()
{
  AOSMTPLib.MailClass oSmtp = new AOSMTPLib.MailClass();
  oSmtp.FromAddr = "test@emailarchitect.net";
  oSmtp.Subject = "Test";
  oSmtp.BodyText = "Hello, this is a test....";
  
  string[] recipients = new string[2];
  recipients[0] = "support@adminsystem.net";
  recipients[1] = "test@hotmail.com";
  
  for( int i = 0; i < recipients.Length; i++ )
  {
    oSmtp.ClearRecipient();
    oSmtp.AddRecipient( recipients[i], recipients[i], 0 );
    oSmtp.ServerAddr = "";     
    if( oSmtp.SendMail() == 0 )
      Console.WriteLine( "Message to {0} delivered!", recipients[i] );
    else
      Console.WriteLine( "Message to {0} failed: {1}", 
                        recipients[i], 
                        oSmtp.GetLastErrDescription());
  }
}
-Jack

Solution  Solution

02-Nov-08 02:01 PM
Hi,

You NEED an SMTP server to send email regardless of the programming/scripting language. The Send Mail Transport Protocol is the standard used for sending email across the internet.

For .NET, most hosts (if your doing web applications) have that already installed, but if your doing a normal application, then you have an SMTP server to send the email. Usually, programmers supply an option in the program so the user can change the SMTP information so that the program could work. I usually allow the user add his email SMTP information into the settings of the program so that he/she could use the email features.

You can send e-mails without SMTP. For more info look at this
http://www.eggheadcafe.com/articles/20030316.asp

You can use algorithm of DNS lookup in ANSMTP which enables your application to send email without SMTP server.
  • How to send email with DNS lookup;

  • How to send email to multiple recipients who don't belong to the same domain.

Installation and Deployment

You should download the http://www.emailarchitect.net/webapp/download/ansmtp.exe and install it on your machine at first.

How does it work?

In general, we send email via specified SMTP server. How does the specified SMTP server know what address this email should be sent to? It queries MX record of recipient's domain via DNS lookup. Then it forwards this email to the SMTP server queried from DNS server. If the recipient's server doesn't work fine, your SMTP server will send an email to tell the sender there is failure in sending this email.

How does ANSMTP work with DNS lookup? ANSMTP queries DNS directly from DNS, then send email to recipient's email server. If it fail, SendMail method will fail in synchronous mode and OnError event will occur (instead of sending an email to tell sender) in asynchronous mode, and your application can do something for this failure. If it fail in sending email via DNS lookup, it will also fail in sending email with specified SMTP server.

Send email without specified SMTP server

We just need to assign "" to ServerAddr property of ANSMTP, ANSMTP would send email via automatically.

C# Example
private void SendEmail()
{
AOSMTPLib.MailClass oSmtp = new AOSMTPLib.MailClass();
//If you don't have a SMTP server, use the following code
//send email via DNS lookup, ANSMTP lookups SMTP server automatically.

oSmtp.ServerAddr = "";

oSmtp.FromAddr = "test@adminsystem.net";
oSmtp.AddRecipient( "Support Team", "support@adminsystem.net", 0 );

oSmtp.Subject = "Test";
oSmtp.BodyText = "Hello, this is a test....";

if( oSmtp.SendMail() == 0 )
Console.WriteLine( "Message delivered!" );
else
Console.WriteLine( oSmtp.GetLastErrDescription());
}

Limitations with DNS lookup

If you specified multiple recipients,  make sure all recipients' email addresses belong to the same domain, otherwise "Error with sending recipient" occurs.

C# Example
private void SendEmail()
{
AOSMTPLib.MailClass oSmtp = new AOSMTPLib.MailClass();
//If you don't have a SMTP server, use the following code
//send email via DNS lookup, ANSMTP lookups SMTP server automatically.

oSmtp.ServerAddr = "";

oSmtp.FromAddr = "test@emailarchitect.net";
//Correct, both support@adminsystem.net and test@adminsystem.net
//belong to adminsystem.net

oSmtp.AddRecipient( "Support Team", "support@adminsystem.net", 0 );
oSmtp.AddRecipient( "Tester", "test@adminsystem.net", 1 );


oSmtp.Subject = "Test";
oSmtp.BodyText = "Hello, this is a test....";

if( oSmtp.SendMail() == 0 )
Console.WriteLine( "Message delivered!" );
else
Console.WriteLine( oSmtp.GetLastErrDescription());
}

The code below shows how to send email to multiple recipients who don't belong to the same domain.

C# Example
private void SendEmail()
{
AOSMTPLib.MailClass oSmtp = new AOSMTPLib.MailClass();
oSmtp.FromAddr = "test@emailarchitect.net";
oSmtp.Subject = "Test";
oSmtp.BodyText = "Hello, this is a test....";

string[] recipients = new string[2];
recipients[0] = "support@adminsystem.net";
recipients[1] = "test@hotmail.com";

for( int i = 0; i < recipients.Length; i++ )
{
oSmtp.ClearRecipient();
oSmtp.AddRecipient( recipients[i], recipients[i], 0 );
oSmtp.ServerAddr = "";
if( oSmtp.SendMail() == 0 )
Console.WriteLine( "Message to {0} delivered!", recipients[i] );
else
Console.WriteLine( "Message to {0} failed: {1}",
recipients[i],
oSmtp.GetLastErrDescription());
}
}


Mail Server  Mail Server

02-Nov-08 11:45 PM
IMO, the best way of sending low volume mails programmatically is to use GMail rather than expend resources setting up & maintaining your own mail server.

Adapt this snippet -

System.Net.Mail.MailMessage mail = new System.Net.Mail.MailMessage();

System.Net.NetworkCredential cred = new System.Net.NetworkCredential("yourid@gmail.com", "yourpwd");

mail.To.Add("acme@acme.com");
mail.Subject = "subject";

mail.From = new System.Net.Mail.MailAddress("yourid@gmail.com");
mail.IsBodyHtml = true;
mail.Body = "message";

System.Net.Mail.SmtpClient smtp = new System.Net.Mail.SmtpClient("smtp.gmail.com");
smtp.UseDefaultCredentials = false;
smtp.EnableSsl = true;
smtp.Credentials = cred;
smtp.Port = 587;
smtp.Send(mail);

Source: http://mvark.blogspot.com/2006/09/sending-mail-programmatically-using-c.html
try this link  try this link
03-Nov-08 10:07 AM

http://www.topshareware.com/IPCheck-Server-Monitor-download-893.htm

http://www.topshareware.com/ArGoSoft-Mail-Server-Freeware-download-9467.htm

http://www.topshareware.com/No-Spam-Today%21-for-Servers-Freeware-download-8582.htm

http://www.topshareware.com/free-smtp-server/downloads/1.htm


http://www.filecart.com/Windows/Servers/Mail-Servers/st-SMTP-Server_3412.html
http://smtp-email-server.qarchive.org/
http://free-email-server.vista-files.org/
http://www.bestfreewaredownload.com/freeware/t-free-free-smtp-server-freeware-gqggwnwa.html
Create New Account
help
configure smtp server in my system how to configure smtp server in my system am using windows 7 os To Use the UI • Open IIS Manager in the UI, see Navigation in IIS Manager (IIS 7) . • In Features View , double-click SMTP E-mail . • On the SMTP E-mail page, type the e-mail address of the sender in the E-mail address text
Error while sending mail in application. Hi All, I get following error while I try to send a mail thr' application. "Function evaluation disabled because a previous function evaluation timed out. You must continue evaluation." and here goes my code. . . . . MailMessage oMsg = new MailMessage(); / / TODO: Replace with sender e-mail address. oMsg.From = " sender@somewhere.com "; / / TODO: Replace with recipient e-mail address. oMsg.To = " recipient@somewhere.com "; oMsg.Subject = "Send Using Web Mail"; / / SEND IN HTML FORMAT (comment this line to send plain text). oMsg.BodyFormat = MailFormat.Html MailAttachment oAttch = new MailAttachment(sFile, MailEncoding.Base64); oMsg.Attachments.Add(oAttch); / / TODO: Replace with the name of your remote SMTP server. SmtpMail.SmtpServer = "MySMTPServer"; SmtpMail.Send(oMsg); oMsg = null; oAttch = null
I tried to. . . Of course it is not a problem for a user with a SMTP server access or a registered domain with a SMTP server access . But unfortunately I had neither of those. I use MSN, GMail and Yahoo for my mailing needs. Unfortunately Yahoo does not offer SMTP or POP access for its general / basic / free users. And MSN is not that reliable sent and received and as far as I know, they do not give you POP / SMTP access ! Typical Example You Will Find On the Internet So I really hunted for a code segment that will help me use my free GMail account to send E-mail from my .NET account . Here is a complete reference library and FAQs regarding the System Web.Mail namespace. And my code is basically different pieces joined together. Finally I met with success
void MailSystem() / / Call this method in button_Click event { / / NameSpace to be use: using System.Net.Mail; MailMessage mail = new MailMessage(); mail.From = new MailAddress( "kalit.s@Mailclient.com" , "kalit sikka" ); mail.ReplyTo = new MailAddress( "EndUser@Mailclient.com" , "Rely To" ); mail.To.Add( "kalit.s@ Mailclient.com mail.Subject = "Auto Generated" ; mail.Body = "User: " + Environment.UserName + "<br> <br> " + "Machine-name " + Environment.MachineName + "<br> <br> IP Address" + WINLibKSVR01.ClsCore.mGetIPAddress() + "<br> <br> " + "Running application from invalid