Почтовый ящик smpt не работает
Всем привет,
Я создал почтовый ящик. Это не работает. Пожалуйста, может ли кто-нибудь сказать мне, почему это так?
Я создал это, посмотрев видео. я не знаю, дал ли я ему номера портов и все такое. Это нормально или я хочу изменить его, и как я могу это сделать?
Он показывает мне такое сообщение об ошибке
**Error Message** Server Error in '/' Application. The remote name could not be resolved: 'smpt.gmail.com' 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.WebException: The remote name could not be resolved: 'smpt.gmail.com' Source Error: Line 66: //pass account information to the sender Line 67: tsmtpClient.Credentials = new System.Net.NetworkCredential("kasuniscg8@gmail.com", "kasuchin321"); Line 68: tsmtpClient.Send(tmailmessage); Line 69: Line 70: Source File: c:\Users\A\Desktop\Food new one\Backup\11-21\Food Calorie Calculator- Final Project\Food Calorie Calculator- Final Project\Admin\MailBox.aspx.cs Line: 68 Stack Trace: [WebException: The remote name could not be resolved: 'smpt.gmail.com'] System.Net.ServicePoint.GetConnection(PooledStream PooledStream, Object owner, Boolean async, IPAddress& address, Socket& abortSocket, Socket& abortSocket6) +6646520 System.Net.PooledStream.Activate(Object owningObject, Boolean async, GeneralAsyncDelegate asyncCallback) +307 System.Net.PooledStream.Activate(Object owningObject, GeneralAsyncDelegate asyncCallback) +19 System.Net.ConnectionPool.GetConnection(Object owningObject, GeneralAsyncDelegate asyncCallback, Int32 creationTimeout) +324 System.Net.Mail.SmtpConnection.GetConnection(ServicePoint servicePoint) +141 System.Net.Mail.SmtpTransport.GetConnection(ServicePoint servicePoint) +170 System.Net.Mail.SmtpClient.GetConnection() +44 System.Net.Mail.SmtpClient.Send(MailMessage message) +1554 [SmtpException: Failure sending mail.] System.Net.Mail.SmtpClient.Send(MailMessage message) +1906 Food_Calorie_Calculator__Final_Project.Admin.MailBox.SenEmail(String from, String to, String cc, String bcc, String subject, String body, Boolean IsHTML) in c:\Users\A\Desktop\Food new one\Backup\11-21\Food Calorie Calculator- Final Project\Food Calorie Calculator- Final Project\Admin\MailBox.aspx.cs:68 Food_Calorie_Calculator__Final_Project.Admin.MailBox.btn_Send_Click(Object sender, EventArgs e) in c:\Users\A\Desktop\Food new one\Backup\11-21\Food Calorie Calculator- Final Project\Food Calorie Calculator- Final Project\Admin\MailBox.aspx.cs:29 System.Web.UI.WebControls.Button.OnClick(EventArgs e) +9628114 System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +103 System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +10 System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +13 System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +35 System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1724
Что я уже пробовал:
**aspx.cs** public partial class MailBox : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { } //Click event: send button protected void btn_Send_Click(object sender, EventArgs e) { string _from = "foodcaloriecalculator@gmail.com"; string _to = txt_to.Text.Trim(); string _cc = txt_cc.Text.Trim(); string _bcc = txt_bcc.Text.Trim(); string _subject = txt_sub.Text.Trim(); string _body = txt_body.Text.Trim(); //calling method SenEmail(_from,_to, _cc, _bcc, _subject, _body,true); } private static void SenEmail(string from,string to,string cc, string bcc, string subject,string body,bool IsHTML) { //create an instant in mail message MailMessage tmailmessage = new MailMessage(); //assign sender mail address tmailmessage.From = new MailAddress(from); //asssign recipiant email address tmailmessage.To.Add(new MailAddress(to)); //check if cc/bcc is not null if (cc != null && cc != "") tmailmessage.CC.Add(new MailAddress(cc)); if (bcc != null && bcc != "") tmailmessage.Bcc.Add(new MailAddress(bcc)); //assign the subject tmailmessage.Subject = subject; //assign the mail body tmailmessage.Body = body; //assign the format into mail box tmailmessage.IsBodyHtml = IsHTML; //assign the prority of the mail into normal tmailmessage.Priority = MailPriority.Normal; //subject encoding by UTF-8 tmailmessage.SubjectEncoding = System.Text.Encoding.UTF8; //body encoding by UTF-8 tmailmessage.BodyEncoding = System.Text.Encoding.UTF8; //Create a new instance of SMTP client and pass name port number from SMPT gmail server SmtpClient tsmtpClient = new SmtpClient("smpt.gmail.com", 587); //enable SSL of theamtp client tsmtpClient.EnableSsl = true; //use delivery method as network tsmtpClient.DeliveryMethod = SmtpDeliveryMethod.Network; //use the Credentials set to false tsmtpClient.UseDefaultCredentials = false; //pass account information to the sender tsmtpClient.Credentials = new System.Net.NetworkCredential("foodcaculator@gmail.com", "kachin321"); tsmtpClient.Send(tmailmessage); } }
Bryian Tan
smpt или smtp?
F-ES Sitecore
смпт? foodcaculator? Если вы не можете использовать google, чтобы узнать, как пишутся вещи, то Программирование, вероятно, будет выше вашего понимания.