on .NET Framework , allows applications to send e-mail by using the Simple Mail Transfer Protocol (SMTP)
Questions tagged [smtpclient]
1275 questions
10
votes
5 answers
What caused the Socket Exception while sending email from Console application?
I'm trying to write a basic console app that will send an email. The problem is that I keep getting the Socket exception:
An attempt was made to access a socket in a way forbidden by its access permissions xxx.xxx.x.xxx:25
I turned off my windows…

anetafr
- 167
- 1
- 3
- 12
9
votes
2 answers
MailKit.Net.Smtp.SmtpClient SMTP server does not support authentication
I'd like to use MailKit to send an email through our Exchange server, using the credentials of the process.
Building up a System.Net.Mail.SmtpClient and NetworkCredential with domain/username/password works, but while using…

Ezhumalai
- 163
- 1
- 2
- 10
9
votes
5 answers
C# SMTP email sending code fails for Yahoo Mail but works fine for other servers, can anyone help?
I am using this code to send an SMTP email via the yahoo SMTP server, it is for a personal project I am writing.
using System.Net.Mail;
using System.Net;
SmtpClient theClient = new SmtpClient("smtp.mail.yahoo.com",…

David Honess
- 153
- 1
- 1
- 5
9
votes
1 answer
The server response was: 5.7.1 Unable to relay/Mailer Daemon
I have gone through the answer to the below question and found it to be very helpful. However, I have a different question regarding the behavior of smtp servers.
Mailbox unavailable
and Relay configuration
Scenario:
I have two smtp servers which I…

Syed Osama Maruf
- 1,895
- 2
- 20
- 37
9
votes
5 answers
SmtpClient can't send; Thunderbird can
This should be pretty routine, right?
public static SmtpClient GetSmtpClient()
{
var client = new SmtpClient
{
Host = _smtpServer,
UseDefaultCredentials = false,
Credentials = new NetworkCredential(_smtpUsername,…

Shaul Behr
- 36,951
- 69
- 249
- 387
9
votes
2 answers
Can send emails through Gmail account only if account has "Access for less secure apps" enabled
If my Gmail account has Access for less secure apps disabled, then my application can't send emails through this account. Instead I get "The SMTP server requires a secure connection or the client was not authenticated. The server response was: 5.5.1…

bckpwrld
- 1,159
- 1
- 11
- 23
9
votes
6 answers
How to validate smtp credentials before sending mail?
I need to validate the username and password set in an SmtpClient instance before sending mail. Using this code:
SmtpClient client = new SmtpClient(host);
client.Credentials = new NetworkCredential(username,password);
client.UseDefaultCredentials =…

Manish Gupta
- 449
- 2
- 6
- 16
9
votes
2 answers
Why do we periodically get "An asynchronous call is already in progress" when calling SmtpClient.Send?
We have some (synchronous) email code, which creates a class that creates an SmtpClient, and then sends an email. The SmtpClient is not reused; however we get the following exception every now and then:
System.Web.HttpUnhandledException…

Danny Tuppeny
- 40,147
- 24
- 151
- 275
9
votes
2 answers
What's the default timeout on the SmtpClient object?
What does the timeout default to in the .NET SmtpClient object? What unit of time is it (seconds, milliseconds, etc)?

Daniel
- 10,864
- 22
- 84
- 115
9
votes
2 answers
SmtpClient hangs with no exception thrown if wrong port was specified
I was trying to send emails in my Asp.Net C# application using port 465 with host "smtp.gmail.com" but the whole application hangs (keeps loading). When debugging it's stuck at SmtpClient.Send(msg).
Regardless of the credentials specified, it…

Osama Mortada
- 171
- 3
- 12
9
votes
1 answer
Send email in secure way
I'm trying to make a simple application which will send an email. I use MailMessage and SmtpClient classes. SmpClient requires a login and password to work.
Is it secure to compile application with login/password in simple string?
Is this possible…

apocalypse
- 5,764
- 9
- 47
- 95
9
votes
4 answers
Unable to send emails to external domain using SMTP
I am not able to send emails to external domain addresses like 'user.one@asdf.com' using the code below.
SmtpClient smtpClient = new SmtpClient(smtpMailServer);
smtpClient.UseDefaultCredentials = true;
smtpClient.DeliveryMethod =…

Murali B
- 835
- 2
- 8
- 7
9
votes
2 answers
The server response was: 4.3.2 Service not available, closing transmission channel
I am getting this error while sending email from my application. Can anyone suggest any solution.
Service not available, closing transmission channel. The server
response was: 4.3.2 Service not available, closing transmission
channel
Below is…

techblog
- 529
- 2
- 5
- 16
9
votes
1 answer
Send email with attchement using System.Net.Mail thows exception: Cannot access a closed file
I am using System.Net.Mail to send emails through my application. I was trying to send emails with the attachments with following code.
Collection MailAttachments = new Collection();
MailAttachments.Add("C:\\Sample.JPG");
…

udaya726
- 1,010
- 6
- 21
- 41
8
votes
1 answer
The SMTP host was not specified
i want to send mail to user when registered but error (The SMTP host was not specified)
how to i configure smtp in web.config?

Farhood
- 197
- 3
- 5
- 9