猿问

jmail使用

这是我写的例子,加上端口后就转圈圈,不加的话,也没发送成功哪里出错了呢?

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();
胡说叔叔
浏览 326回答 2
2回答

回首忆惘然

参考代码一:jmail 4.5使用gmail smtp ssl解决方法 参考代码二:Java Jmail中配置Gmail配置 Gmail 的 SMTP 用了SSL,需要解决 SSL 验证的问题。
随时随地看视频慕课网APP
我要回答