CDO.Message 메일 보내기
간단히 서버에서 테스트 할 수 있는것 기재 하였습니다.
아참 혹시나 해서 하는 이야기 인데요.. 2000 에서는 CDONTS 를 지원하는데 2003에서는 CDONTS 지원 안된다는거 아지요? 만약 CDONTS 를 지원하길 원하신다면 cdonts.dll 파일을 레지스트리에 등록 해주세요 ^^
스크립트 인용 (테오 싸이트).
<%
Set objMail = Server.CreateObject("CDONTS.NewMail")
objMail.From="username@ABC.com" ' 자신의 E-mail 주소를 쓰세요
objMail.To="username@ABC.com" ' 받는이도 자신의 E-mail 주소를 쓰세요
objMail.Subject="새로운 메일이다." '이건 제목입니다.
objMail.Body="cdo를 이용한 메일이다..테스트이지롱~~~ "
objMail.importance=0
objMail.Send
Set objMail = nothing
%>
Response.Write "메일발송완료"
CDO.Message 를 이용한 메일 보내기.
1번째 예시.
<%
Const cdoSendUsingPort = 1SET objMessage = Server.CreateObject("CDO.Message")
SET objConfig = createobject("CDO.Configuration")'''''''''''''''''' Setting the SMTP Server ''''''''''''''''''''''''
SET Flds = objConfig.FieldsWith Flds
.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = cdoSendUsingPort
.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "localhost"
.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
.Item("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 30
.update
End WithSET objMessage.Configuration = objConfig
With objMessage
.From = "winadmin@xxx.com"
.To = "win@yyy.com"
.CC = ""
.Subject = "메일테스트"
.HTMLBody = "메일내용입니다.".DSNOptions = 14
.Fields("urn:schemas:mailheader:return-receipt-to") = "winadmin@xxx.com"
.Fields("urn:schemas:mailheader:disposition-notification-to") = "winadmin@xxx.com".BodyPart.Charset="ks_c_5601-1987"
.HTMLBodyPart.Charset="ks_c_5601-1987"
.Fields.update
.Send
End WithSET objConfig = Nothing
SET objMessage = Nothing
%>
Response.Write "메일 보내기 완료"
* Const cdoSendUsingPort = 1 에서 이 부분을 0으로 설정하면 타 서버의 SMTP를 사용할 수 있습니다. 그러면 당연히
Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "localhost"
부분도 변경이 되야 겠지요? localhost 가 아닌 서버 IP 로.
CDO.Message 메일 보내기
2번째 예시. (자료출처 태오 사이트)
set objMessage = createobject("cdo.message")
set objConfig = createobject("cdo.configuration")
' Setting the SMTP Server
Set Flds = objConfig.Fields
Flds.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
Flds.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "localhost"
Flds.update
Set objMessage.Configuration = objConfig
objMessage.To = "you@yourdomain.com" '보내는 사람 이메일 주소
objMessage.From = "someone@somewhere.com" '받는 사람 이메일 주소
objMessage.Subject = "This is a sample email sent using CDO" '제목
objMessage.TextBody = "Congratulation" & VbCrLf & "If you receive this is, your mail component works"
' 메일 내용이 HTML 형식이면 objMessage.TextBody 대신에 objMessage.HTMLBody를 사용
objMessage.fields.update
objMessage.Send
Response.write "발송 완료!!!!"
set objMessage = nothing
set objConfig = nothing
간단하죠?
참고로 로컬 서버에서 사용하실 때 유동 아이피 쓰시는 분들은 아이피 세팅시에
자동 DNS 아이피 받기로 하지 마시고 꼭 특정한 DNS 서버 아이피를 따로 설정해서 사용하세요.
안그럼 메일들이 발송 안되고 큐폴더로 떨어진답니다.