Click here to Skip to main content
15,883,711 members
Everything / SMTP

SMTP

SMTP

Great Reads

by JosipK, Marko Kozlina
C# and VB.NET console applications that demonstrate how to create and send an email reply with IMAP and SMTP protocols in .NET Framework
by Uzi Granot
The attached open source C# .NET library is an SMTP client implementing implicit SSL and OAuth2 protocols. The library answers the question: how to send email message using Gmail as a server. Or, how to send email message using email server that implements implicit SSL and port 465.
by DataBytzAI
Easy way to send email on Azure with no mail server, using DNS MX and SMTP
by ObiWan_MCC
A C# SMTP server (receiver).

Latest Articles

by Jason Sultana
Understanding and preventing Newline Injection
by DiponRoy
How to run FTP, SFTP, SMTP, Cache, LDAP, SSO and other servers in Docker
by Uzi Granot
The attached open source C# .NET library is an SMTP client implementing implicit SSL and OAuth2 protocols. The library answers the question: how to send email message using Gmail as a server. Or, how to send email message using email server that implements implicit SSL and port 465.
by DataBytzAI
Easy way to send email on Azure with no mail server, using DNS MX and SMTP

All Articles

Sort by Score

SMTP 

15 Jun 2016 by JosipK, Marko Kozlina
C# and VB.NET console applications that demonstrate how to create and send an email reply with IMAP and SMTP protocols in .NET Framework
20 Jun 2019 by Uzi Granot
The attached open source C# .NET library is an SMTP client implementing implicit SSL and OAuth2 protocols. The library answers the question: how to send email message using Gmail as a server. Or, how to send email message using email server that implements implicit SSL and port 465.
4 Feb 2018 by DataBytzAI
Easy way to send email on Azure with no mail server, using DNS MX and SMTP
19 Dec 2011 by Robert S Sharp
I'm not sure that GC would matter very much in such a simple app.But, it's either a call to Dispose on your SmtpClient after you're done using it:smtp.Dispose();or use a using:using (SmtpClient smtp = new SmtpClient{ Host = "smtp.gmail.com", Port = 587, Credentials = new...
28 Dec 2015 by Dhruti90
MVC functionalities with web service with simple integration
21 May 2011 by thatraja
Windows Services!Read these articles.Sending Bulk Emails using Window-services[^]Send Mass Email in C# with Multiple Threads[^]Ready-to-use Mass Emailing Functionality with C#, .NET 2.0, and Microsoft® SQL Server 2005 Service Broker[^]
5 Dec 2014 by Tadit Dash (ତଡିତ୍ କୁମାର ଦାଶ)
Refer - Cannot get email to work with GoDaddy email SMTP[^]. Implement this.Quote:SymptomsUsing GoDaddy SMTP server smptout.secureserver.net email errors occur such as: Mail Error occurred - Exception=Failure sending mail. Unable to read data from the transport connection:...
8 Sep 2014 by cogi83
A SW to send your WAN IP and other info via email
14 Jul 2015 by F-ES Sitecore
You need to speak to whoever administers the smtp server you are using and ask them what you need to do to allow relaying, or to configure relaying as possible from internal servers. Basically the problem isn't your code, it is configuration.
8 Jun 2012 by Manas Bhardwaj
try this:public void Base64ToImage(string base64String, string fileName){ byte[] imageBytes = Convert.FromBase64String(base64String); using (MemoryStream ms = new MemoryStream()) { ms.Write(imageBytes, 0, imageBytes.Length); using (FileStream fileStream =...
26 Aug 2012 by TorstenH.
Please use a local Email-Server for testing: http://www.hmailserver.com/[^]It's free.your provider will limit the number of accesses to the pop/smtp and might also ban you completely if you try to shoot the SMTP/POP with strange commands.Your ExceptionThe remote name could not be...
13 Dec 2012 by Orcun Iyigun
Well I agree to Sergey that doing something such like that is not easy and you cannot be sure whether it is send or not. I would rather not to go that way you asked but if you really do need to:Here is an approach that you might want to try: You can create an httphandler for your website...
22 Jul 2013 by Ron Beyer
Quote:Message would bring account over daily quotaGet a mailbox with a bigger quota.[Edit]Here's a prime example of getting an error and jumping to a conclusion without understanding the error itself. Taking the time to read the error can point you directly to the problem (over daily...
5 Aug 2013 by Sergey Alexandrovich Kryukov
I don't know how come you could not find any.Please see this CodeProject article: SMTP Server[^].Maybe you need to look better? Please see: http://bit.ly/13fo2Xc[^].—SA
11 Oct 2013 by ASP.NET Community
Following Codes demonstrates how to send an email with SMTP Authentication using ASP.NET 3.5using System.Net.Mail        MailMessage msgMail =
20 Mar 2015 by manchanx
1) You need the email-addresses of your users - you probably already have them.2) When clicking on a user name or as an option in a users profile a form for writing a message to that user should be accessible.3) When the user confirms to send the message, you send it to the recipients...
2 Jun 2020 by OriginalGriff
Normally, I'd address the mail to a "noreply" email address on my domain and attach all genuine recipients as BCC addressees, rather than trying to add them as "To" addresses. That way, each recipient does not receive a list of every other...
3 Jun 2020 by MadMyche
The MailMessage.To property is not a string value; it is actually a collection of email addresses To add to this collection; you generally would use the Add() method, just like you did for the first recipient.msg.To.Add(new...
25 May 2011 by Member 980284
First off you have to have a "storage" for emails.It could be a message queueu or database.Do not try to send large number of eamils in a loop - it will not work.Then, you need a windows service.The service will wake up, say every 30 seconds (you may and should write an algorithm for how...
28 May 2011 by #realJSOP
It's probably because your email server doesn't allow relays.
3 Aug 2011 by OriginalGriff
Look at MailMessage.To[^]- it is a standard List, so you can provide as many addresses as you want via the Add method.
6 Oct 2011 by phil.o
Your SMTP server should be configured to be authoritative for one domain (i.e. mydomain.com). Better choose a mail domain name that is more representative (mydomain.com seems way too much generic).
21 Dec 2011 by coded007
Quote:mail.Fro...
22 Dec 2011 by coded007
look over this http://www.astahost.com/info/tilffm-sending-mail-net.html[^]
13 Jan 2012 by Richard MacCutchan
This article[^] may help you. Google may help you more.
19 Jul 2012 by Mehdi Gholam
Most email server require authentication for SMTP sending to block anonymous spam emails.Configure your email server to require SMTP authentication.
12 Sep 2012 by Prasad_Kulkarni
This error message is quite self-explanatory: The remote name could not be resolved: 'wmail.link.net' You cannot create a connection to the SMTP server you have specified. There is nothing wrong with your code. You just need to check why you can't access the SMTP ('wmail.link.net')...
3 Nov 2012 by Jason Gleim
You can't do this. You can lookup the MX record for the domain but that is the inbound mail exchanger and, quite simply, it won't accept mail from your program. If it did, every spammer in the world would do what you are asking to do. Mail servers (like GMail, Yahoo, etc) want things like...
2 Jan 2013 by Josh Hawley
The server is not "muppets.com". That is their domain name. You have to do a DNS look up to get the MX records for muppets.com and then use those MX records to get A record(s) for their mail server(s).You can do this manually using nslookup (Easily done with code as well):Default Server: ...
8 Jan 2013 by Manas Bhardwaj
User credentials for SMTP server serves no purpose more than to authenticate while sending an email. It ensures that noone with proper credentials could send an email via the server.And, this has no relation to the delivery receipt.
1 Feb 2013 by Dee_Bee
Hi all,I tried with fileUpload and found the solution. mail.Attachments.Add(new Attachment(fileUpload.PostedFile.InputStream, fileUpload.FileName)); Thank you all
10 Mar 2013 by H.Brydon
You might think you are only involving 2 systems here but there are at least 3.When you send an email to a conventional email address, you are really sending it to a mail server. The protocol used to send to the server is (usually) SMTP. [The email server may or may not be the SMTP...
10 Mar 2013 by Vishwanath.284
http://static.springsource.org/spring/docs/2.0.x/reference/mail.html[^]
22 Jul 2013 by Mehdi Gholam
You have to wait a day!The message states that you are going over your daily quota.
17 Aug 2013 by jkirkerx
Your on the right track!, I'm not an expert at SMTP but I do have a couple hundred hours into it.When using a mail server to relay a message to it's destination, your not really logging in to the mail server, your just passing a SMTP message through it as long as you meet the criteria of the...
22 Jan 2014 by dwayne905
On Window 2008 R2 try using RegAsm from the 64Bit .NET folder if 32bit folder doesn't work for you.
13 Mar 2014 by Dave Kreskowiak
This has nothing to do with your code and there is nothing you can do about it, other than changing the server you're using to send mail.It's telling you, point blank, that the server REQUIRES the sender address to match the account that was used to login to the SMTP server. You cannot get...
26 May 2014 by Member 10844988
using System.Net;using System.Net.Mail;using System.Net.Mime; private void button1_Click(object sender, EventArgs e) { SmtpClient Smtp = new SmtpClient("smtp.gmail.com", 587); //SMTP server and port number Smtp.Credentials = new...
29 May 2014 by karthik Udhayakumar
Hello Priyanka,There are many causes for this to occur,with your code iam unable to identify the issueYou can refer these quickly to try and solve...
21 Jun 2014 by Peter Leow
Check this out: PHPMailer tutorial[^]
4 Dec 2014 by forccyy
Below is the code I am using for sending mail from my local. I have WCF class library project where this code is written. I am calling this function from ASP.net website.I am getting error :"Mail not sent : The SMTP server requires a secure connection or the client was not authenticated....
2 Feb 2022 by Raj Negi
I am trying to send email by using ASP.NET C# code. My website is hosted in godaddy server. It gives this error: Unable to read data from the transport connection: net_io_connectionclosed. using System.Net.Mail; using MailMessage =...
20 Mar 2015 by Afzaal Ahmad Zeeshan
You should know that there is something know as a variable in programming. Which can be filled with any value that your application (or more specifically "you") want to use. So for example, if you use the WebMail class to send the email, then the following code would be used,// client,...
14 Apr 2015 by Jochen Arndt
You are using the wrong SMTP server (it did not accept mails from the abcd.fr domain) or there is an authentication problem (as already noted by Richard).Use the same settings as in your mail client for the abcd.fr account (SMTP server, port, authentication method). The settings should be...
20 Jul 2016 by OriginalGriff
Depends on your hosting service - they will tell you exactly what to use, but the code I use is here: Sending an Email in C# with or without attachments: generic routine.[^] and for Host in my web.config file I use:
20 Aug 2016 by Karthik_Mahalingam
provide the activation page url in the href attributebody += "Click here to activate your account.";
17 Dec 2016 by Afzaal Ahmad Zeeshan
Continuing from the comments, 587 is correct port for Yahoo Mail and default TCP port for SMTP 25 also works, that is standard based and not Yahoo specific. The problem is with your username/password combination, you need to check them out to make sure they are correct. Sending emails over...
26 Jan 2017 by Afzaal Ahmad Zeeshan
Your code looks fine to me, and it should send the email (and of course, should connect to the server), did you try connecting through the default TCP port for SMTP communication? That is 25, consider trying that one out, using (SmtpClient smtp = new SmtpClient("smtp.gmail.com", 25))Other than...
6 Feb 2018 by Maciej Los
If you would like to validate if email is correct, you can do it, but if you would like to check if email exists, it's almost impossible. See: php - How to check if an email address exists without sending an email? - Stack Overflow[^] How to check if email address exists?[^]
14 Feb 2018 by phil.o
Usually, you cannot, at least not in a reliable way. SMTP servers tend to prohibit real-address checking, and it is a good thing as it makes spammers' life much more difficult. You can only validate that an email address is well-formed. There are already numerous questions here about that, you...
14 Feb 2018 by OriginalGriff
You can't check it: mostly because it prevents spammers from finding live email addresses and carpet bombing them with rubbish. You can check if it's a valid email address: Google[^] but the opnly way to know if an address is "real" is to send it an email that the user must respond to - that is...
2 Aug 2020 by Garth J Lancaster
This line in your code Quote: using (SmtpClient smtp = new SmtpClient("darylds2001@gmail.com", 587)) is certainly wrong - the SmtpClient constructor takes the SMTP Host/Server ie email server ie "smtp.gmail.com" I know not from there this...
6 Oct 2020 by Sandeep Mewara
If I understand correct, you seek to highlight some text while sending an email. For highlighting text via some color, you would need to use HTML or RTF format of text. This would enable you to have text formatting that can be sent in an email....
11 Aug 2022 by TheRealSteveJudge
It is recommended to use the newer System.Net.Mail.MailMessage class. MailMessage Class (System.Net.Mail) | Microsoft Docs[^] Then you must place a using statement on top of your code. using System.Net.Mail; This here is also worth reading:...
19 Jan 2023 by Dave Kreskowiak
If you're using the SMTP route into Outlook365, you do not have the option of turning SentItems off. On normal servers, using SMTP does not put anything in SentItems, but Office365 is not the standard email environment the web uses. Things are a...
24 Sep 2023 by Graeme_Grant
With GMail, you don't use your normal account and password. You need to generate a "special" app paasword for the email address that you want to use. Please read this: Sign in with app passwords - Gmail Help[^] Here is a quick'n'dirty (tested &...
3 Mar 2024 by Jason Sultana
Understanding and preventing Newline Injection
21 May 2011 by mnd017
Hi, First of all, im not spamming. I want to write an application, sending large volumes of email for financial companies - for sending information emails. The application will be windows forms or windows service (sending emails saved in db). What is the best way (not the easiest), to do...
26 May 2011 by XtremLucky
I am trying to implement a simple mailing functionality into my application using the following code But it gives some Error while is invoke Send method on SmtpMail obj ..Please help ...!!private void button1_Click(object sender, EventArgs e) { try { ...
26 May 2011 by XtremLucky
Actually This Works :try { SmtpClient mailClient; mailClient = new SmtpClient("smtp.gmail.com", 587); //mailClient.Credentials = new NetworkCredential("MyGmailEmail@gmail.com", "MyGmailPassword"); //enable ssl mailClient.EnableSsl =...
28 May 2011 by se.nishant
i have a problem in sending emails...i have a application i am using system.net.mail namespace when i run my application in visual studio in my system its working perfectly.. but when i uploaded my site to server it creates problem emails are not sending when i use my site from there.....
27 Jul 2011 by dhawaljoshi
Hi All,My Question is when we send mails through a SMTP Server and if we enter a wrongly spelt email id or a wrong id, then a bounce back mail will be sent where is it sent from the server? can anyone explain.
27 Jul 2011 by dhawaljoshi
Hi ,This can be a simple one for you guys but please let me know where does SMTP Log File Resides which may be containing the bounced back email and other email related logs.
2 Aug 2011 by dhawaljoshi
hi my qusetion for today is how can we send mail through a smtp email client to a distribution list or a group of people.
7 Sep 2011 by joe_j
hi,i have a wesite hosted on a windows server 2003. with .net4.i need an email to be send out to my when an error occurs. i am able to achieve this on my xp as i can get the smtp, but not able to find the smtp setting in IIS in the server. does anyone know how get this workingthanks
7 Sep 2011 by Wendelius
From http://www.google.com/#hl=en&q=send+email+from+asp.net[^].For example this could be promising: http://www.4guysfromrolla.com/articles/072606-1.aspx[^]
25 Sep 2011 by CarrieEJ
Hi,I've set up IIS 7 on Windows server 2008 R2 and have enabled SMTP.In the SMTP E-Mail Settings there is an option to store e-mails in a pickup directory for later delivery.I was wondering if it is possible to change the email extention to a .pickup extention before it has been...
3 Oct 2011 by solutions.software
Dear members ,my application requires to send emails. the email's body needs to have a specific format.The format and the content is defined in a MS Word document.i can select and copy the contents of the document into the clipboard. Question is how do i send the data in the clipboard as...
3 Oct 2011 by Al Moje
Hi,I think you could do it by Attachment on you smtp email...See this link if it could help....System.Net.Mail FAQRemember to vote if it help...Regards,Algem
6 Oct 2011 by Sharad Mishra
I am getting "Mailbox unavailable. The server response was: 5.4.1 Unable to relay for myemail@mydomain.com" when I try to send the mail using C# code.Then I tested my smtp server at https://www.wormly.com/test_smtp_server.Here when I enter my smtp server, sender and recipient name. I got...
6 Oct 2011 by Sharad Mishra
I am getting "Mailbox unavailable. The server response was: 5.4.1 Unable to relay for myemail@mydomain.com" when I try to send the mail using C# code.Then I tested my smtp server https://www.wormly.com/test_smtp_server".Here when I enter my smtp server, sender and recipient name. I got...
18 Oct 2011 by shashikanth 2011
protected void btnSendmail_Click(object sender, EventArgs e) { // System.Web.Mail.SmtpMail.SmtpServer is obsolete in 2.0 // System.Net.Mail.SmtpClient is the alternate class for this in 2.0 SmtpClient smtpClient = new SmtpClient(); ...
11 Mar 2012 by Mehdi Gholam
Sending emails to Google's server require you to be on port 587 using EnableSSL=true and to be authenticated first on Google ie with an account ending in @gmail.com etc.[edit]Changed 589 to 587[/edit]
26 Oct 2011 by MiguelSanchezCuarental
Hello everyone.I had a problem when I am going to send an e-mail.I have the following code:this.m_oSmtpCliente.Host = this.m_sSMTPSERVER;this.m_oSmtpCliente.Port = 587;this.m_oSmtpCliente.EnableSsl = true;this.m_oSmtpCliente.DeliveryMethod =...
26 Oct 2011 by Manfred Rudolf Bihy
A reverse lookup revealed that the IP you gave resolves to the FQDN ww-in-f109.1e100.net. Is this a machine on your network?To check if the machine is reachable you can try to ping it. This only gives reliable information if ICMP is enabled in your network up to the machine you are trying to...
26 Oct 2011 by Richard MacCutchan
I have just tested this on my system and it works correctly. The only difference being that I did not specify a port number in the SMTP client. Why have you selected port 587 in your test, when the defaults are 25 for non-SSL and 465 for SSL type mail?
21 Nov 2011 by jim lahey
Please note I don't want to take anything away from roosrj's tip which displays infinitely more in depth knowledge about the SMTP protocol than I can - as a lazy man's alternative I've always used PostCast v2.6 to test anything mail related:...
8 Dec 2011 by Peta2010
Hi I am creating website and sending email I have this line in email msg body mail.Body = "Hi, you got Job. Here are the details of passengers " & vbCrLf & " " & vbCrLf & "Passenger name: " + Me.nameTextBox.Text + "" & vbCrLf & "" & vbCrLf & " Phone number: " + Me.phoneTextBox.Text...
8 Dec 2011 by OriginalGriff
SelectedItem does not return a string: it returns a ListItem.Try using SelectedValue instead.
12 Dec 2011 by Saloni_Bal
Im trying to send mail using SendAsync method of SmtpClient.But the SendCompleted event doesnt fire, though Im getting mails (after around 20 minutes delay!)Googling it says, that MailMessage object is Disposed (using statement) before SendCompleted firesI will be using the mailsend...
12 Dec 2011 by Ganesan Senthilvel
SendCompleted event doesn't really mean the previous send completed, it means that you can do another SendData without it blocking. In other words it means there is room to buffer more outgoing data.Effectively though this is the same thing. Thus you can generally treat it as meaning the...
22 Dec 2011 by Peta2010
Hi Guys,I am facing this issue to send email from my website to linked mail account.User not local; please try a different path. The server response was: Sender address is not valid for your login. Check your email program settings.Exception Details: System.Net.Mail.SmtpException:...
8 Jan 2012 by CGN007
Hi,How can I request Delivery Status Notification in SMTPand how can I parse it?I,m using this asmailmessage.DeliveryNotificationOptions = DeliveryNotificationOptions.OnSuccess;Mailing is success,but I'm not getting any delivery status.Can anyone identify the reason ?By using ...
13 Jan 2012 by Cr4zYPT
Good Afternoon,I'm building a email client that uses smtp to send email, but i have a small problem.Some smtp servers such as gmail/hotmail require SSL.Example:me:EHLO localhostme:auth loginsv:.... requires STARTTLSSo i send the comand STARTTLS and it replies 220 2.0.0 SMTP...
23 Jan 2012 by cutexxbaby
i have trying to on how to do on reseting password by emailhowever when i click on the button it prompt "The remote name could not be resolved: 'myemail@hotmail.com' at System.Net.ServicePoint.GetConnection(PooledStream PooledStream, Object owner, Boolean async, IPAddress& address, Socket&...
23 Jan 2012 by Jaganathan Bantheswaran
Hi,The smpt.Host should be like,smtp.Host = "smtp.live.com" // whatever the mail server for the hotmail
26 Jan 2012 by 07navneet
I want to send an email to my gmail id from my web application. For now I was sending from my same id(i.e. from/to on same ID).Code: SmtpClient smtpClient = new SmtpClient(); MailAddress fromAddress = new MailAddress("navneet7988@gmail.com"); ...
26 Jan 2012 by Sudip Saha
can you please use below codesmtpClient.DeliveryMethod = SmtpDeliveryMethod.Network
26 Jan 2012 by Rajesh Anuhya
use the below code to send the emailMailMessage oMsg = new MailMessage(); oMsg.From = new MailAddress("xxx@gmail.com", "xxx"); oMsg.To.Add(new MailAddress("yyy@gmail.com", "xxx")); oMsg.Subject = "Packet Parsing Problem"; ...
26 Jan 2012 by Bojjaiah
The remote name could not be resolved: 'smpt.gmail.com'you are using smpt.gmail.cominsted of this smtp.gmail.com => use it's working MailAddress mailfrom = new MailAddress ( "frommail@gmail.com" ); MailAddress mailto = new MailAddress ( "tomail@gmail.com" ); ...
27 Jan 2012 by Mukund Thakker
You can try following link, Send mail using Google Apps[^] Hope this may help you!
27 Jan 2012 by Bryian Tan
hi 07navneet,Your original code is fine. Let try this. Ping the smtp.gmail.com, get its IP address and replace the smtp.gmail.com in your code with the IP address.Thanks,Bryian Tan
7 Feb 2012 by biki66
Hi,When trying to send an email using gmails SMTP server I get the following error:"Service not available, closing transmission channel. The server response was: Cannot connect to SMTP server 173.194.67.108 (173.194.67.108:587), connect timeout"My code is as...
7 Feb 2012 by Bojjaiah
MailAddress mailfrom = new MailAddress ( "frommail@gmail.com" ); MailAddress mailto = new MailAddress ( "tomail@gmail.com" ); MailMessage newmsg = new MailMessage ( mailfrom, mailto ); newmsg.Subject = "Subject of Email"; newmsg.Body =...
8 Feb 2012 by Sanjay K. Gupta
use SmtpClient client = new SmtpClient("smtp.gmail.com");instead of SmtpClient client = new SmtpClient("smtp.gmail.com", 587);