English 中文(简体)
我怎样才能用经典的 Asp 从本地主机应用程序发送邮件?
原标题:How can I send mail from my localhost application using classic asp

我用这个和我的服务器发送邮件。 这非常有效。 我想试一下我的本地主机应用程序。

    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 = "[email protected]"

            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
最佳回答

检查您的本地机器能否到达 SMTP 服务器。 它可能会被一些防火墙或路由器封住 。 此网站可以对您进行一次简单的检查 : < a href=" http://www. canyouneseeme. org/" rel=" nofollow > http://www. canyouseememe.org/

当然,您也可以在代码中检查,也可以通过Telnet:http://www.sproperts.de/smtp-check-port-25-telnet-command.htm

问题回答

Here is the contents of an include file I created for sending emails: [note at the top it includes another include that has a fn_dirty() for the purpose of adding things like quotes back in.] ask me if you want that function.

<!-- #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,[email protected];Andy,[email protected]" etc
    array_recipients = split(s_recipients_list,";",-1,1)

     so recipients array now looks like this:
     array_recipients(0) = "Scott,[email protected]"
     array_recipients(1) = "Andy,[email protected]"  

     -- 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
%>




相关问题
sendmail() php help

I am getting an error while sending a mail from a form Failed to connect to mailserver at "mail.yoursite.com" port 25, verify your "SMTP" and "smtp_port" setting in php.ini or use ini_set() in C:...

mail: failed to open stream: Permission denied?

I get this warning sending mails with php Warning: mail(1) [function.mail]: failed to open stream: Permission denied in /home/... using ssmtp and gmail as smtp PHP 5.3.1 nothing in the logs (no ...

Google App Engine: Sendmail, command not found

I m trying to get sendmail working on localhost. The problem is that the app engine has det wrong path to sendmail, since it throws the error: /bin/sh: sendmail: command not found Using Mac OS X, the ...

Is there a library for reading /var/spool/mail/ files?

How does one parse the mail files generated on a Linux system using Java? I mean, I want to be able to extract the From, To, Timestamp and Subject of the various emails inside the file. Any ...

postfix relay failover [closed]

Is there a way to configure postfix to use a relay only if direct delivery is rejected? The case being a web application that has to send notification to subscribers, but some servers reject the ...

Zend 邮件问题,涉及外国char子+ com子

泽斯德邮局在名称被定为具有外国性质(如“保”)和 com(”)的物品时,就放弃了一种例外(因为邮局(邮局)退回假)。 重新提出以下守则。

寄送电子邮件时

当我试图从与PHPmailer同时发送电子邮件时,有时会向每个接收者发送2份,有时发送3份同一电子邮件(如随机发送)。

热门标签