郵件伺服器源碼
Ⅰ 求java實現郵件發送的源代碼
import java.util.*;
import javax.mail.*;import javax.mail.internet.*;
public class JMail {
public void SendMail(String Topic,String Content){ Properties props=new Properties(); props.put("mail.smtp.host","smtp.163.com"); props.put("mail.smtp.auth","true"); Session s=Session.getInstance(props); s.setDebug(false); MimeMessage message=new MimeMessage(s); MimeMultipart mp=new MimeMultipart(); BodyPart body = new MimeBodyPart(); InternetAddress from; InternetAddress to; try{ from=new InternetAddress("發件人郵箱"); message.setFrom(from); to = new InternetAddress("收件人郵箱"); message.setRecipient(Message.RecipientType.TO,to); message.setSubject(Topic,"utf-8"); body.setContent(Content, "text/html;charset=utf-8"); mp.addBodyPart(body); message.setContent(mp); message.setSentDate(new Date()); message.saveChanges(); Transport transport=s.getTransport("smtp"); transport.connect("smtp.163.com(郵件服務商,這是163的)","發件郵箱","發件郵箱密碼"); transport.sendMessage(message,message.getAllRecipients()); transport.close(); } catch(AddressException e){ e.printStackTrace(); } catch(MessagingException e){ e.printStackTrace(); } }}
Ⅱ 易語言發送郵件源碼怎麼寫啊
首先,在軟體的界面創建「標簽1」「標簽2」,並改名為「郵件標題」「郵件內容」,也可按照自己的想法修改(針對應用於其他特殊需要用戶)創建,「編輯框1」「編輯框2」「按鈕1」,並將「按鈕1」改名為「發送郵件」
雙擊「發送郵件」按鈕,進入代碼編輯區域
連接「發信伺服器」,並判斷是否連接成功,代碼:如果 (連接發信伺服器 (「smtp.163.com」, 25, 「你的163郵箱賬戶」, 「你的163郵箱密碼」, ) = 真)
這里判斷如果連接發信伺服器成功,將執行發送郵件,代碼:發送郵件 (編輯框1.內容, 編輯框2.內容, 「這里寫你收信的郵件地址」, , , 「這里寫你的發信郵箱地址」, )
這里判斷如果連接發送伺服器失敗的話,將執行彈出信息框代碼,當然也可省略這個步驟,根據個人需要選擇,代碼:信息框 (「連接發信伺服器失敗」, 0, )
此時,完整的代碼如下:
.版本 2支持庫 internet如果 (連接發信伺服器 (「smtp.163.com」, 25, 「你的163郵箱賬戶」, 「你的163郵箱密碼」, ) = 真)發送郵件 (編輯框1.內容, 編輯框2.內容, 「這里寫你收信的郵件地址」, , , 「這里寫你的發信郵箱地址」, )否則信息框 (「連接發信伺服器失敗」, 0, , )
「編輯框1」是郵件標題,「編輯框2」是郵件內容,填寫完之後,點擊「發送郵件」按鈕,即可。
Ⅲ 100高分誠求:Java郵件系統源代碼
你的這個要求有點離譜,如果真的要的話
建議去這個找吧,源代碼都有的
Ⅳ 易語言中郵件收發源碼
Word:
.版本 2
.支持庫 pop3
.支持庫 internet
.子程序 Button_Click
.局部變數 Email, 郵件信息
.局部變數 Nember, 整數型
.局芹隱部變數 Size, 整數型
' Send E-mail
.判斷開始 (連接發信伺服器 (「smtp.qq.com」, 21, 「296901441」, 「qwe296901441」, ))
.默認
信息框 (「Worry!」中滲, 0, )
返回 ()
.判斷結束
發送郵件 (「Oh!」, 「My qq:296901441」, 「[email protected]」, , , 「[email protected]」, )
' Find E-mail
.判斷開始 (連接收信伺服器 (「pop.qq.com」, 110, 「296901441」, 「qwe296901441」, 30000, 3))
.默認
信息框 (「Worry!」, 0, )
返回 ()
.判斷結束
獲取郵件信息 (Nember, Size)
.判斷開始 (Nember = 0)
信息框 (「Don't have mails!」, 0, )
返賣首脊回 ()
.默認
.判斷結束
Email = 接收郵件 (1).取主題 () ' Find zhe title of the first mail.
Ⅳ Jmail群發郵件的源碼
試試以下代碼:核心就是循環調用發郵件代碼就可以了
<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<%
Server.ScriptTimeOut=9999999
Response.Buffer = True
dim FoundErr, ErrMsg, Action
dim MailServerUserName, MailServerPassWord, MailDomain, MailServer
dim MailtoAddress, MailtoName, Subject, MailBody, FromName, MailFrom, Priority
FoundErr = False
ErrMsg = ""
Action = Trim(Request("action"))
ComeUrl = ""
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE>群發郵件系統</TITLE>
<META http-equiv=Content-Type content="text/html; charset=gb2312">
<META content="Microsoft FrontPage 4.0" Name=GENERATOR>
<STYLE type=text/css>
a {text-decoration: none;} /* 鏈接無下劃線,有為underline */
a:link {color: #000000;text-decoration: none;} /* 未訪問的鏈接 */
a:visited {color: #000000;text-decoration: none;} /* 已訪問的鏈接 */
a:hover {color: #ff6600;text-decoration: none;} /* 滑鼠在鏈接上 */
a:active {color: #000000;text-decoration: none;} /* 點擊激活鏈接 */
TD {
FONT-SIZE: 18px; COLOR: #000000; FONT-FAMILY: '宋體';LINE-HEIGHT: 150%;
}
BODY {
FONT-SIZE: 12px; COLOR: #000000; FONT-FAMILY: '宋體'
}
INPUT {
FONT-SIZE: 12px; COLOR: #000000; FONT-FAMILY: '宋體'
}
SELECT {
FONT-SIZE: 12px; COLOR: #000000; FONT-FAMILY: '宋體'
}
.title
{
background:#0DB432;
color: #ffffff;
font-weight: normal;
}
.border
{
border: 1px solid #0DB432;
}
.tdbg{
background:#f0f0f0;
line-height: 120%;
}
.tdbg1{
background:#A3E2B1;
line-height: 120%;
}
</STYLE>
</HEAD>
<BODY text=#000000 bgColor=#ffffff leftMargin=0 topMargin=0>
<br>
<%
Select Case Action
Case "send"
Call sendMail()
Case Else
Call Main()
End Select
If FoundErr = True Then
Response.Write WriteErrMsg(ErrMsg, ComeUrl,"錯誤信息")
End If
Response.write"</BODY></HTML>"
sub main()
If Not IsObjInstalled("JMail.Message") Then
FoundErr=True
ErrMsg = "伺服器不支持JMail組件,請正確安裝"
Exit Sub
End If
%>
<form action="wssf.asp?Action=send" method=post>
<table width="80%" class="border" border="0" cellspacing="1" cellpadding="4" align="center" height="589">
<tr>
<td height="40" colspan="2" align="center" class="title">
<p><b> 群發郵件系統</b></p> </td>
</tr>
<tr>
<td width='30%' class='tdbg1' height="25"><strong>郵件伺服器地址:</strong> </td>
<td class='tdbg' height="25">
<input name='MailServer' type='text' id='MailServer' value='smtp.163.com' size='40'> <FONT color=#ff0000>*</FONT>
</td>
</tr>
<tr>
<td width='30%' class='tdbg1' height="25"><strong>登錄用戶名一:</strong>
</td>
<td class='tdbg' height="25">
<input name='MailServerUserName1' type='text' id='MailServerUserName1' value='XXX' size='40'> <FONT color=#ff0000>*</FONT>
</td>
</tr>
<tr>
<td width='30%' class='tdbg1' height="25"><strong>登錄密碼一:</strong>
</td>
<td class='tdbg' height="25">
<input name='MailServerPassWord1' type='password' id='MailServerPassWord1' value='***' size='40'> <FONT color=#ff0000>*</FONT>
</td>
</tr>
<tr>
<td width="30%" class="tdbg1" height="25">您的姓名:</td>
<td class="tdbg" height="25"><input name="name" type=text id="name" size=30>
<FONT color=#ff0000>*</FONT></td>
</tr>
<tr>
<td width="30%" class="tdbg1" height="25">您的E-mail:</td>
<td class="tdbg" height="25"><input name="email" type=text id="email" value="[email protected]" size=30>
<FONT color=#ff0000>*</FONT></td>
</tr>
<tr>
<td width="30%" class="tdbg1" height="25">收件人姓名:</td>
<td class="tdbg" height="25"><input name="toname" type=text id="toname" size=30>
<FONT color=#ff0000>*</FONT></td>
</tr>
<tr>
<td width="30%" class="tdbg1" height="25">收件人Email:</td>
<td class="tdbg" height="25"><input name="toemail" type="text" id="toemail" size="30" maxlength="100">
<FONT color=#ff0000>*</FONT></td>
</tr>
<tr>
<td width="30%" class="tdbg1" height="25">郵件標題:</td>
<td class="tdbg" height="25"><input type=text name="topic" size=30>
<FONT color=#ff0000>*</FONT></td>
</tr>
<tr>
<td width="30%" class="tdbg1" height="500">郵件內容:</td>
<td class="tdbg" height="500"><textarea name="body" cols=74 rows=34 id="body"></textarea>
<FONT color=#ff0000>*</FONT></td>
</tr>
<tr>
<td width="30%" class="tdbg" height="27"></td>
<td height=27 class="tdbg">
<input type="Submit" value="發送郵件" name="Submit">
<input type="reset" name="Clear" value="重新填寫">
</td>
</tr>
</table>
</form>
<%
End Sub
Sub sendMail()
MailServer = trim(Request("MailServer")) 'SMTP伺服器地址:smtp.163.com, 請修改
MailServerUserName = trim(Request("MailServerUserName")) 'SMTP登錄用戶名:[email protected], 請修改
MailServerPassWord = trim(Request("MailServerPassWord")) 'SMTP登錄密碼:***, 請修改,注意大小寫
MailDomain = trim(Request("MailDomain")) 'SMTP域名:163.com, 請修改
FromName = trim(Request("name")) '發件人名字
MailFrom = trim(Request("email")) '發件人郵箱
MailtoName = trim(Request("toname")) '發件人名字
MailtoAddress=trim(Request("toemail")) '收件人郵箱
Subject = trim(Request("topic"))
MailBody = trim(Request("body"))
Priority=3
If FromName="" or MailFrom="" or MailtoName="" or Subject="" or MailBody="" then
FoundErr = True
ErrMsg = "請填寫完整每一項信息!"
Exit Sub
End If
ErrMsg = JSendMail()
If ErrMsg<>"" Then
FoundErr = True
Exit Sub
Else
Response.Write WriteErrMsg("", ComeUrl,"成功信息")
End If
End Sub
Function JSendMail()
On Error Resume Next
JSendMail = ""
Dim JMail,tempMessage
Set JMail = Server.CreateObject("JMail.Message")
JMail.silent=true
JMail.Logging = True
JMail.Charset = "gb2312" '郵件編碼
JMail.silent = True
JMail.ContentType = "text/html" '郵件正文格式
JMail.ServerAddress=MailServer '用來發送郵件的SMTP伺服器
'如果伺服器需要SMTP身份驗證則還需指定以下參數
JMail.MailServerUserName = MailServerUserName1 '登錄用戶名
JMail.MailServerPassWord = MailServerPassWord1 '登錄密碼
JMail.AddRecipient MailtoAddress, MailtoName '收信人
JMail.Subject = Subject '主題
JMail.HtmlBody = MailBody '郵件正文(HTML格式)
JMail.Body = MailBody '郵件正文(純文本格式)
JMail.FromName = FromName '發信人姓名
JMail.From = MailFrom '發信人Email
JMail.Priority = Priority '郵件等級,1為加急,3為普通,5為低級
Dim emailArray
If MailtoAddress="" then
set fsObj = Server.CreateObject("Scripting.FileSystemObject")
FilePath = Server.MapPath("email.txt")
set txtsObj = fsObj.OpenTextFile(FilePath, 1, false)
i = 0
Do While Not txtsObj.atEndOfStream
emailArray(i)=txtsObj.ReadLine
JMail.AddRecipient Trim(emailArray(i)),MailtoName
i=i+1
loop
Else
JMail.AddRecipient MailtoAddress, MailtoName
End If
JMail.Send (MailServer)
tempMessage = JMail.ErrorMessage
JMail.Close
Set JMail = Nothing
If tempMessage<>"" then
FoundErr = True
JSendMail = tempMessage
end if
Set JMail = Nothing
End Function
Function IsObjInstalled(strClassString)
On Error Resume Next
IsObjInstalled = False
Err = 0
Dim xTestObj
Set xTestObj = CreateObject(strClassString)
If Err.Number = 0 Then IsObjInstalled = True
Set xTestObj = Nothing
Err = 0
End Function
Function WriteErrMsg(sMsg, sComeUrl,Massages)
Dim strMsg
strMsg = strMsg & "<html><head><title>"&Massages&"</title><meta http-equiv='Content-Type' content='text/html; charset=gb2312'>" & vbCrLf
strMsg = strMsg & "</head><body><br><br>" & vbCrLf
strMsg = strMsg & "<table cellpadding=2 cellspacing=1 border=0 width=400 class='border' align=center>" & vbCrLf
strMsg = strMsg & " <tr align='center' class='title'><td height='22'><strong>"&Massages&"</strong></td></tr>" & vbCrLf
if FoundErr=True Then
strMsg = strMsg & " <tr class='tdbg'><td height='100' valign='top'><b>產生錯誤的可能原因:</b>" & sMsg & "</td></tr>" & vbCrLf
Else
strMsg = strMsg & " <tr class='tdbg'><td height='100' valign='top'><br><b>恭喜,成功用JMail發送郵件!</b>" & sMsg & "</td></tr>" & vbCrLf
End If
strMsg = strMsg & " <tr align='center' class='tdbg'><td>"
If sComeUrl <> "" Then
strMsg = strMsg & "<a href='javascript:history.go(-1)'><< 返回上一頁</a>"
Else
strMsg = strMsg & "<a href='javascript:window.close();'>【關閉】</a>"
End If
strMsg = strMsg & "</td></tr>" & vbCrLf
strMsg = strMsg & "</table>" & vbCrLf
strMsg = strMsg & "</body></html>" & vbCrLf
WriteErrMsg = strMsg
End Function
%>
Ⅵ 求用C#寫的郵件客戶端源代碼
private void SendMail()
{
string returnStr = "";
try
{
string KL = "";//發件人郵箱地址
string PSW = "";/租稿/發件人郵箱密碼
MailMessage msg = new MailMessage();
msg.To.Add(KL);
msg.From = new MailAddress(「收件人郵件地址」, "support", System.Text.Encoding.UTF8);//收件人
msg.Subject = "郵件主題";
msg.SubjectEncoding = System.Text.Encoding.UTF8;
msg.Body += "郵件正文";
Attachment myfile = new Attachment("附件路徑");//附件
msg.Attachments.Add(myfile);
msg.BodyEncoding = System.Text.Encoding.UTF8;
msg.IsBodyHtml = true;
msg.Priority = MailPriority.High;
SmtpClient client = new SmtpClient();
client.Host = "smtp.qq.com";//郵件伺服器
client.UseDefaultCredentials = false;
client.Credentials = new System.Net.NetworkCredential(KL, PSW);//發件人
client.Send(msg);
returnStr = "郵件已老型衫發送,侍腔請注意查收!";
}
catch (Exception)
{
returnStr = "郵件發送失敗,請確認您的郵箱是否存在!";
}
HttpContext.Current.Response.ContentType = "text/plain";
HttpContext.Current.Response.Write(returnStr);
HttpContext.Current.Response.Flush();
HttpContext.Current.Response.End();
}