PDA

View Full Version : مشکل در ارسال ایمیل از طریق میل هاست



kezack
پنج شنبه 31 مرداد 1387, 21:23 عصر
با سلام من می خوام از طریق میل هاست برای افراد میل بفرستم ولی با این خطا مواجه شدم لطفا کمکم کنید

No connection could be made because the target machine actively refused it 127.0.0.1:25

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Net.Sockets.SocketException: No connection could be made because the target machine actively refused it 127.0.0.1:25

Source Error:

Line 29: Line 30: Line 31: smtp.Send(mail);Line 32: }Line 33: کد برنام این هست
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;
using Persia;
using System.Net.Mail;
using System.ComponentModel;
publicpartialclass TirUser_CountantUs : System.Web.UI.Page
{
protectedvoid Page_Load(object sender, EventArgs e)
{
}
protectedvoid btnadd_Click(object sender, EventArgs e)
{
MailMessage mail = new MailMessage();
mail.From = new MailAddress("admin@tirkaranco.com");
mail.To.Add("taha_tmm@yahoo.com");
mail.Subject = "This is an email";
mail.Body = "this is the body content of the email .";
SmtpClient smtp = new SmtpClient("127.0.0.1");
smtp.Send(mail);
}

mostafa_sgh
جمعه 01 شهریور 1387, 01:16 صبح
دوست عزیز

البته این رو هم در نظر داشته باشید ، بعضی از هاستینگها از پورت 25 برای SMTP استفاده نمیکنند.
اینم در نظر بگیرید ، شاید اجازه استفاده ازش رو نداشته باشید .

مگر هاستتون Mail Server نداره ، چرا از اون استفاده نمیکنید ؟ ( من دیدم سایتشو ، داره ! )

از این روش برا ارسالش استفاده کنید ....




MailMessage message=new MailMessage();

message.From = new MailAddress("admin@tirkaranco.com");
message.To.Add(new MailAddress("taha_tmm@yahoo.com"));

message.Subject = "Mail Subject";
message.Body = "Mail Body";

//message.Priority = MailPriority.High;
message.IsBodyHtml = false;
SmtpClient client = new SmtpClient("mail.tirkaranco.com");
System.Net.NetworkCredential basicAuthentication = new System.Net.NetworkCredential("admin@tirkaranco.com","AdminPassword");
client.UseDefaultCredentials = false;

client.Credentials = basicAuthentication;

client.Send(message);

kezack
جمعه 01 شهریور 1387, 12:14 عصر
با تشکر از mostafa_sgh (http://barnamenevis.org/forum/member.php?u=67326) ولی باز با این خطا مواجه شدم

Syntax error, command unrecognized. The server response was: relay denied

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Net.Mail.SmtpException: Syntax error, command unrecognized. The server response was: relay denied

Source Error:

Line 37: client.Credentials = basicAuthentication;Line 38: Line 39: client.Send(message);Line 40: Line 41: }

kezack
جمعه 01 شهریور 1387, 12:33 عصر
با تشکر از دوست عزیز mostafa_sgh (http://barnamenevis.org/forum/member.php?u=67326)
مشکلم حل شد و کد شما درست بود:قلب: