I am trying to send an email using a simple button in asp.net. But I am getting following error-"The transport failed to connect to the server".
SmtpMail.SmtpServer = "localhost";
I've used localhost because,I don't know smtp server name of my computer..
how can i fix it? how can I know the SMTP server name?? My os is win xp
hope someone can help me...
To test email locally set up a drop folder called 'maildrop' on your C:\ drive and add the following to your Web.Config file:
<system.net>
<mailSettings>
<smtp deliveryMethod='SpecifiedPickupDirectory'>
<specifiedPickupDirectory pickupDirectoryLocation="c:\maildrop" />
</smtp>
</mailSettings>
</system.net>
ASP.NET: Using pickup directory for outgoing e-mails
UPDATE:
You should be using the newer email library...
using System.Net.Mail;
MailMessage msg = new MailMessage();
msg.To = "[email protected]";
msg.From = "[email protected]";
msg.Subject = "hi";
msg.Body = "yes";
SmtpClient smtpClient = new SmtpClient("localhost");
smtpClient.Send(msg);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With