Yandex Mail is a free, secure and reliable email service. It has many great features:
- Advanced security: It has strong protection from spam and services. Checking emails automatically with anti-virus software.
- Send-it-Later Feature: Schedule to send emails at a specific time.
- Theme customization.
- 10 GB disk space.
If you already have a yandex mail account, you can send programmatically emails via yandex mail.
I have created a very simple console application, to show how can I send an email via Yandex SMTP with c#.
SMTP settings:
- hostname: smtp.yandex.com.tr
- port: 465
But with these settings, it gives timeout error. Finally, I figure out a solution after lots of trial and error.
I was able to make my code work by changing the port number from 465 to 587.
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace testsendmail { class Program { static void Main(string[] args) { var mailUserName = "myusername"; var mailPassword = "mypassword"; var mailSentFrom = "myusername"; var emailListString = "admin@138.68.79.210"; // Configure the client: using (var client = new System.Net.Mail.SmtpClient("smtp.yandex.com.tr") { DeliveryMethod = System.Net.Mail.SmtpDeliveryMethod.Network }) { // client.Port = 465; // Gives timeout error client.Port = 587; client.UseDefaultCredentials = false; client.EnableSsl = true; // Create the credentials: var credentials = new System.Net.NetworkCredential(mailUserName, mailPassword); client.Credentials = credentials; // Create the message: var mail = new System.Net.Mail.MailMessage(mailSentFrom, emailListString) { Subject = "test message subject", Body = "test message body" }; try { client.Send(mail); } catch (Exception ex) { Console.WriteLine(ex.Message); } Console.ReadKey(); } } } }
I’m using the SmtpClient dotnet class to create a client object. Create credentials using our own username and password and set to Smtp Client. Lastly, create a MailMessage object and send via Smtp client.
You also have to set UseDefaultCredentials and EnableSsl properties. In our example, we will send an email over SSL/TLS connection in C#.
Note
If you have a domain name, you can use your domain name as an email address like johndoe@mydomain.com. I explain step by step how to create a business email address for free.
Get Free Business Email Address Which Uses Your Domain Name (Turkish)