using System;
using System.Net;
using System.Net.Mail;
class Program
{
static void Main(string[] args)
{
try
{
string smtpServer = "mail.example.com"; //SMTP sunucusu adresi
int port = 587; //SMTP sunucusu port numarası
string senderEmail = "sender@example.com"; //Gönderen e-posta adresi
string password = "password"; //Gönderen e-posta hesabının şifresi
string recipientEmail = "recipient@example.com"; //Alıcı e-posta adresi
MailMessage mail = new MailMessage();
mail.From = new MailAddress(senderEmail);
mail.To.Add(recipientEmail);
mail.Subject = "Test Email"; //E-posta konusu
mail.Body = "This is a test email."; //E-posta içeriği
SmtpClient smtpClient = new SmtpClient(smtpServer, port);
smtpClient.UseDefaultCredentials = false;
smtpClient.Credentials = new NetworkCredential(senderEmail, password);
smtpClient.EnableSsl = true;
smtpClient.Send(mail);
Console.WriteLine("E-posta gönderildi.");
}
catch (Exception ex)
{
Console.WriteLine("E-posta gönderirken bir hata oluştu: " + ex.Message);
}
}
}