Windows Sunucu ASP.NET örnek SMTP mail gönderim scripti Yazdır

  • windows, plesk, smtp, mail, gönderim, örnek
  • 64

SMTP ile mail göndermeden önce hosting hesabınız altında mail hesabı oluşturmanız gerekiyor.


<%@ Import Namespace="System.Net" %>
<%@ Import Namespace="System.Net.Mail" %>

<script language="C#" runat="server">
protected void Page_Load(object sender, EventArgs e)
{
//create the mail message
MailMessage mail = new MailMessage();

//set the addresses
mail.From = new MailAddress("mail@alanadiniz.com"); // Buraya mail kullanici adini girin
mail.To.Add("mail@gonderilecekdomain.com");  // mail gönderilecek adres

//set the content
mail.Subject = "This is an email"; // mail konusu
mail.Body = "This is from system.net.mail using C sharp with smtp authentication."; // mail içeriği
//send the message
SmtpClient smtp = new SmtpClient("mail.alanadiniz.com"); // SMTP server adresi

NetworkCredential Credentials = new NetworkCredential("postmaster@yourdomain.com", "password"); // buraya mail kullanıcı adı ve şifrenizi girin.
smtp.Credentials = Credentials;
smtp.Send(mail);
lblMessage.Text = "Mail Sent";
}
</script>
<html>
<body>
<form runat="server">
<asp:Label id="lblMessage" runat="server"></asp:Label>
</form>
</body>
</html>


Bu cevap yeterince yardımcı oldu mu?

<< Geri