ServerZoo虛擬主機使用教學文件區 Home      會員列表      Register Now!
舊 2011-05-20, 12:15 PM   #1
Tech-SZ 的頭像
 
Tech-SZ
最高權限

預設 [分享]ASP 表單寄信範例

主機動物園 "舊版Windows網頁空間有支援兩種mail 元件

*ASPemail
*CDOSYS

您需要到您控制台去新增EMAIL帳號,然後使用SMTP認證於程式內
記得EMAIL帳號為 name@網址.com 需要全打,然後SMTP server 為 mail.網址.com,然後記得mail.from 那邊要和SMTP驗證的EMAIL一樣,例如您用service@domain.com驗證,然後mail.from 那邊就需要用service@mail.com ,SMTP 的PORT為25 或587

以下是ASPEMAIL範例

引用:
<% Set objMail = Server.CreateObject("Persits.MailSender")

'SMTP位址
objMail.Host = "mail.domain.com"
'Email 使用者名稱 一定要用我們主機上新增的EMAIL帳號,@後面都要打
objMail.Username = "user@domain.com"
'EMAIL 使用者密碼
objMail.Password = "********"

objMail.From = "userl@domain.com" '需要跟上面帳號一樣
objMail.AddAddress "mail@123domain.com" '收件者電子信箱
objMail.Subject = "Mail Subject" '主題
objMail.Body = "Test message." '內容

On Error Resume Next
objMail.Send

If Err = 0 then
txtMsg = "信件寄送完成"
Else
txtMsg = "信件寄送失敗"
End If
%>
教學
http://www.siamasp.com/components/AspEmail/Manual.htm
http://www.verywl.com/wlbc/ShowArtic...rticleID=16908

亂碼問題? 可以試試看整合以下這些參數
引用:
ObjSendMail.Subject = Mail.EncodeHeader( "Subject", "utf-8")
ObjSendMail.CharSet = "UTF-8"
ObjSendMail.ContentTransferEncoding = "Quoted-Printable"

此篇文章於 2015-02-02 10:17 PM 被 Tech-SZ 編輯。.
Show SignatureDisplay Signature 回覆時引用此篇文章
舊 2011-07-11, 04:06 PM   #2
Tech-SZ 的頭像
 
Tech-SZ
最高權限

預設

使用 CDO.Message 物件 SMTP 驗證發信

一樣需要用自己的MAIL帳密喔

代碼:
<%
Dim ObjSendMail
Set ObjSendMail = CreateObject("CDO.Message")  
     
'This section provides the configuration information for the remote  SMTP server.
     
ObjSendMail.Configuration.Fields.Item   ("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2 'Send  the  message using the network (SMTP over the  network).
ObjSendMail.Configuration.Fields.Item  ("http://schemas.microsoft.com/cdo/configuration/smtpserver")  ="mail8.pzen.com"
ObjSendMail.Configuration.Fields.Item  ("http://schemas.microsoft.com/cdo/configuration/smtpserverport") =  587
ObjSendMail.Configuration.Fields.Item   ("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = False  'Use SSL  for the connection (True or False)
ObjSendMail.Configuration.Fields.Item  ("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") =  60
     
' If your server requires outgoing authentication uncomment the  lines bleow and use a valid email address and  password.
ObjSendMail.Configuration.Fields.Item   ("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1  'basic  (clear-text) authentication
ObjSendMail.Configuration.Fields.Item  ("http://schemas.microsoft.com/cdo/configuration/sendusername")  ="EMAIL打在這 例如webmaster@domain.com"
ObjSendMail.Configuration.Fields.Item  ("http://schemas.microsoft.com/cdo/configuration/sendpassword")  ="密碼打在這"
     
ObjSendMail.Configuration.Fields.Update
     
'End  remote SMTP server configuration section==
     
ObjSendMail.To =  "sales@serverzoo.com"
ObjSendMail.Subject = "this is the  subject"
ObjSendMail.From = "from的EMAIL要跟您上面STMP驗證的email adress一樣 例如webmaster@domain.com"
     
' we are  sending a text email.. simply switch the comments around to send an html email  instead
'ObjSendMail.HTMLBody = "this is the body"
ObjSendMail.TextBody =  "this is the body"
     
ObjSendMail.Send
     
' Set ObjSendMail =  Nothing 
%>


一般ASP 使用 CDO.Message + SMTP 發信


引用:
<%
Set myMail=CreateObject("CDO.Message")
myMail.Subject="a test message here"
myMail.From="這個也要填 例如master@mail.com"
myMail.To="sales@serverzoo.com"
myMail.TextBody="testing"

myMail.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/sendusing")= 2
myMail.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "您的MAIL主機 例如mail8.pzen.com"
myMail.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = true
myMail.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/sendusername") = "您的EMAIL 例如 webmaster@imail.com"
myMail.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "您的EMAIL密碼"
myMail.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = False
myMail.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 587

myMail.Configuration.Fields.Update
myMail.Send
'set myMail=nothing
%>

此篇文章於 2013-06-18 09:36 PM 被 Tech-SZ 編輯。.
Show SignatureDisplay Signature 回覆時引用此篇文章
回覆

書籤

主題工具
顯示模式

發文規則
不可以發表新主題
不可以發表回覆
不可以上傳附件
不可以編輯自己的文章

啟用 BB 代碼
論壇啟用 表情符號
論壇啟用 [IMG] 代碼
論壇禁用 HTML 代碼

論壇跳轉


所有時間均為台北時間。現在的時間是 08:17 AM


Powered by vBulletin® 版本 3.8.0
版權所有 ©2000 - 2018,Jelsoft Enterprises Ltd.