1

我在我的服务器上使用它来发送邮件。效果很好。我想在我制作的本地主机应用程序上尝试一下。

    Set myMail=CreateObject("CDO.Message")

            myMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
            myMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/bodyformat") = 0 ' 0 - html, 1 - text
            myMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/mailformat") = 0 ' 0 - mime, 1 - text
            myMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "206.183.108.132"
            myMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
            myMail.Configuration.Fields.Update

            myMail.Subject = "Your New Password for Leave App"
            myMail.From = rs("email")
            myMail.To = "somename@domain.com"

            msgg = msgg & "Dear" & " " & session("Username") & vbcrlf & vbcrlf
            msgg = msgg & "This is your new password" & vbcrlf & vbcrlf
            msgg = msgg & "YOUR CHANGED PASSWORD" & vbcrlf
            msgg = msgg & "- - - - - - - - - - - - - - - - - - - - - - - - - - -" & vbcrlf  

            msgg = msgg & "User/Login Name :" & session("Username") & vbcrlf 
            msgg = msgg & "Password :" & request.Form("new_pass2") & vbcrlf 
            msgg = msgg & "- - - - - - - - - - - - - - - - - - - - - - - - - - -" & vbcrlf & vbcrlf 
            msgg = msgg & "Please sign in to your account using the user name and password above." & vbcrlf & vbcrlf
            msgg = msgg & "Thanks" & vbcrlf 

            myMail.TextBody = msgg 
            myMail.Send

            set myMail = nothing
4

2 回答 2

1

检查您的本地计算机是否可以访问 SMTP 服务器。它可能在某些防火墙或路由器中被阻止。这个网站可以为你做一个简单的检查:http: //www.canyouseeme.org/

当然,您可能还想在代码中检查它,或者通过 Telnet:http ://www.simplescripts.de/smtp-check-port-25-telnet-command.htm

于 2012-05-24T08:42:42.837 回答
0

这是我为发送电子邮件而创建的包含文件的内容:[注意在顶部它包含另一个包含 fn_dirty() 用于添加引号之类的内容。] 问我是否需要该功能。

<!-- #INCLUDE FILE = "i_fn_dirty.asp" -->
<%
function email(s_name_from,s_address_from,s_reply_to,s_subject,s_recipients_list,s_msg,s_type_email,s_msg_error_add,s_RemoteHost)

    if (s_msg_error_add<>"") then s_msg_error_add = "<hr>" & vbCrLf & s_msg_error_add
    if (s_RemoteHost="default") then s_RemoteHost = application("s_mail_server")


    'recipients_list = "Scott,scott@changed.net;Andy,andy@changed.net" etc
    array_recipients = split(s_recipients_list,";",-1,1)

    'so recipients array now looks like this:
    'array_recipients(0) = "Scott,scott@changed.net"
    'array_recipients(1) = "Andy,andy@changed.net"  

    '-- Create the Mailer Object
    Set Mailer = Server.CreateObject("SoftArtisans.SMTPMail")

    '-- Set the Mail Properties
    Mailer.RemoteHost = s_RemoteHost
    Mailer.FromName = s_name_from
    Mailer.FromAddress = s_address_from
    if (s_reply_to<>"") then Mailer.ReplyTo = s_reply_to
    Mailer.Subject = s_subject
    a = ""
    For Each Item in array_recipients
        array_data = split(Item,",",-1,1)
        s_name = array_data(0)
        s_email_addr = array_data(1)
        if (s_name<>"" and s_email_addr<>"") then
            Mailer.AddRecipient s_name, s_email_addr
            a = a & "name: " & s_name & ", email: " & s_email_addr & " | "
        end if
    Next
    if (s_type_email = "text") then
        Mailer.BodyText = s_msg
    else
        s_msg_html = replace(s_msg,vbCrLf,"<br>",1,-1,1)
        Mailer.HTMLText = s_msg_html
    end if

    '-- Fire off the email message
    if (Mailer.SendMail) then
        'yay it worked
        Set Mailer = Nothing
    else
        'try one more time
        if (Mailer.SendMail) then
            'yay it worked
            Set Mailer = Nothing
        else
            msg = "<br>Error in i_fn_email.asp: " & Mailer.Response & "<br>"
            msg = msg & "s_name_from = " & s_name_from & "<br>"
            msg = msg & "s_address_from = " & s_address_from & "<br>"
            msg = msg & "s_subject = " & s_subject & "<br>"
            msg = msg & "recips list = " & a & "<br>"
            msg = msg & s_msg_error_add
            session("msg") = msg
            Set Mailer = Nothing
            response.redirect ("error_report.asp")
        end if
    end if
end function
%>
于 2012-06-01T07:44:53.527 回答