I need to send email from a C# application from localhost. I was successful in sending email using gmail SMPT port and host. But i need send email from local host SMPT virtual server. I followed the steps explained in http://forums.asp.net/t/268037.aspx and http://weblogs.asp.net/steveschofield/archive/2007/08/15/send-email-from-your-local-machine.aspx but the mail was not sending from my application. Also when i execute the command telnet mail.contoso.com 25 in commad promt. It shows "Connecting To mail.contoso.com...Could not open connection to the host, on port
25: Connect failed". Please help me to solve this.
Jump to Post
You should have to enabled - "Internet Mail Server (SMTP)" of firewall.
Jump to Post
use this code for "localhost"
using System.Web.Mail; . . . MailMessage xMailMessage = new MailMessage(); xMailMessage.From = "My Test System <firstname.lastname@example.org>"; xMailMessage.To = "email@example.com"; xMailMessage.Subject = "This is a test"; xMailMessage.BodyFormat = MailFormat.Html; xMailMessage.Body = "<html><head><title>Test emial</title></head><br /><br /><hr>JUST A TEST<hr><br /><br /></body></html>"; SmtpMail.SmtpServer = "localhost"; SmtpMail.Send(xMailMessage); …
All 5 Replies
We're a friendly, industry-focused community of 1.20 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.