这是我写的例子,加上端口后就转圈圈,不加的话,也没发送成功哪里出错了呢?
jmail.Message Jmail = new jmail.Message();
String Subject ="邮件标题";
String body = "邮件内容";
String FromEmail = "cytdsb@gmail.com";
String ToEmail = "1072225929@gmail.com";
Jmail.Silent = true;
Jmail.Logging = true;
Jmail.Charset = "GB2312";
Jmail.ContentType = "text/html";
Jmail.AddRecipient(ToEmail, "", "");
Jmail.From = FromEmail;
Jmail.MailServerUserName = "cytdsb@gmail.com";
Jmail.MailServerPassWord = "123456";
Jmail.Subject = Subject;
Jmail.Body = body;
if (Jmail.Send("smtp.gmail.com:465", false))
Page.RegisterClientScriptBlock("info","<script>alert('发送留言成功!');</script>");
else
Page.RegisterClientScriptBlock("info", "<script>alert('提交留言失败,请检查是否有非法字符!');</script>");
Jmail.Close();
没遇到过这种情况,有此坑爹的是因为jamil版本太低,换个最新版本就对了。
另外确定邮箱本身收发是正常的?我当时用QQ测试是没问题
就是版本问题。。