|
|
|
ส่งเมล์แล้วขึ้น error ยังงี้ Server does not support secure connections. หมายตวามว่ายังงัยครับ |
|
|
|
|
|
|
|
protected void ButtonSubmit_Click(object sender, EventArgs e)
{
System.Net.Mail.MailMessage msg = new System.Net.Mail.MailMessage();
msg.To.Add("[email protected]");
msg.To.Add("[email protected] ");
msg.From = new MailAddress("[email protected]", "Admin", System.Text.Encoding.UTF8);
msg.Subject = "Test mail using .net2.0";
msg.SubjectEncoding = System.Text.Encoding.UTF8;
msg.Body = "This is my msg Body test";
msg.BodyEncoding = System.Text.Encoding.UTF8;
msg.IsBodyHtml = false;
msg.Priority = MailPriority.High;
SmtpClient client = new SmtpClient();
client.Credentials = new System.Net.NetworkCredential("[email protected] ", "******");
client.Port = 25;//or use 587 465
client.Host = "localhost";
client.EnableSsl = true;
client.SendCompleted += new SendCompletedEventHandler(client_SendCompleted);
object userState = msg;
try
{
client.SendAsync(msg, userState);
}
catch (System.Net.Mail.SmtpException ex)
{
Response.write (ex.Message);
}
}
void client_SendCompleted(object sender, AsyncCompletedEventArgs e)
{
MailMessage mail = (MailMessage)e.UserState;
string subject = mail.Subject;
if (e.Cancelled)
{
string cancelled = string.Format("[{0}] Send canceled.", subject);
Page.RegisterClientScriptBlock("OnLoad", "<SCRIPT>alert('" + cancelled + "');</SCRIPT>");
}
if (e.Error != null)
{
string error = String.Format("[{0}] {1}", subject, e.Error.ToString());
}
else
{
}
}
พอกดส่งแล้วมันจะขึ้น Error ครับ
Server does not support secure connections.
อันนี้เป็น Web.config เอามาให้ดูครับ
Web.config
<?xml version="1.0"?>
<!--
Note: As an alternative to hand editing this file you can use the
web admin tool to configure settings for your application. Use
the Website->Asp.Net Configuration option in Visual Studio.
A full list of settings and comments can be found in
machine.config.comments usually located in
\Windows\Microsoft.Net\Framework\v2.x\Config
-->
<configuration xmlns="http://schemas.microsoft.com/.NetConfiguration/v2.0">
<appSettings/>
<connectionStrings>
<add name="DataAlumni" connectionString="Data Source=.\sqlexpress;Initial Catalog=DataAlumni;Integrated Security=True"
providerName="System.Data.SqlClient" />
<add name="DataAlumniConnectionString" connectionString="Data Source=.\SQLExpress;Initial Catalog=DataAlumni;Integrated Security=True"
providerName="System.Data.SqlClient" />
</connectionStrings>
<system.web>
<!--
Set compilation debug="true" to insert debugging
symbols into the compiled page. Because this
affects performance, set this value to true only
during development .
-->
<authorization>
<deny roles="smtp.gmail.com" />
</authorization>
<compilation debug="true">
</compilation>
<!--
The <authentication> section enables configuration
of the security authentication mode used by
ASP.NET to identify an incoming user.
-->
<authentication mode="Forms" />
<!--
The <customErrors> section enables configuration
of what to do if/when an unhandled error occurs
during the execution of a request. Specifically,
it enables developers to configure html error pages
to be displayed in place of a error stack trace.
<customErrors mode="RemoteOnly" defaultRedirect="GenericErrorPage.htm">
<error statusCode="403" redirect="NoAccess.htm" />
<error statusCode="404" redirect="FileNotFound.htm" />
</customErrors>
-->
<globalization uiCulture="th"/>
</system.web>
<!--<system.net>
<mailSettings>
<smtp from="">
<network host="" password="" port="1984" userName="" />
</smtp>
</mailSettings>
</system.net>-->
</configuration>
ช่วยแนะนำด้วยนะครับว่าต้องแก้อะไรบ้าง ผมอยากจะลองส่งในเครื่องของตัวเองดูก่อนนะครับ
Tag : - - - -
|
|
|
|
|
|
Date :
2009-01-27 11:21:23 |
By :
D_jack |
View :
3899 |
Reply :
8 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ผมสงสัยว่าไม่เซ็ทค่า smtp แล้วส่งได้ด้วยหรอครับ
|
|
|
|
|
Date :
2009-01-27 13:11:05 |
By :
tun_sdu |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
แล้วต้องเซ็ทตรงไหนครับ ผมไม่เคยทำมาก่อน ยังงัยช่วยบอกด้วยนะครับ
|
|
|
|
|
Date :
2009-01-27 14:19:04 |
By :
D_jack |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ของผมเขียนงี้อะ SmtpClient SMTPServer = new SmtpClient("smtp.gmail.com");
|
|
|
|
|
Date :
2009-01-27 15:02:33 |
By :
tun_sdu |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
เดี๋ยวจะลองดูนะครับ
|
|
|
|
|
Date :
2009-01-27 21:35:10 |
By :
D_jack |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
แล้วถ้ายังงั้นผมสามารถใช้ stmp ของอะไรได้บ้างครับแล้วจะต้องสมัครมัยครับ
|
|
|
|
|
Date :
2009-01-28 16:54:38 |
By :
D_jack |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 04
|