Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SMTP server name and port

Tags:

asp.net

smtp

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...

like image 795
Sudix Avatar asked Dec 07 '25 13:12

Sudix


1 Answers

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);
like image 184
IrishChieftain Avatar answered Dec 12 '25 17:12

IrishChieftain



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!