【问题标题】:email from SQL ASP来自 SQL ASP 的电子邮件
【发布时间】:2018-04-25 16:13:35
【问题描述】:

我有一个基于 SQL 数据库的门户网站,我们用它来更新进度。当队列中的记录更新时,Web 表单应该发送电子邮件消息。

目前门户网站没有发送消息,我不确定故障点。门户本身正在更新,因为我可以在 SQL 表中看到更新的记录。只是没有收到邮件。

2018 年 4 月 27 日更新

所以我正试图从一个新的途径来解决这个问题,它正在发挥作用......

我所做的是使用 php 将表单发送到外部网站,它会发送一封电子邮件。

我想知道如何传递变量?我已经阅读了一个小时的说明,这对我来说毫无意义。

基本上我想从以下查询中传递一个变量

thequery = "SELECT loginemail FROM users WHERE referrerId = " & request.Form("referrerID")  & ""
objRS.open thequery, objConn, adOpenStatic, adLockReadOnly

然后用类似这样的方式传递它

<form action="https://xxxxxx.com/hello.php?loginemail" method="post" name="updateclientform" id="updateclientform">

在 php 表单端根据变量“loginemail”发送电子邮件

$to = trim(objRS("loginemail"));

有人帮忙吗?请

【问题讨论】:

  • 如有疑问,请查看您的数据。以objRS.recordcount 开头。此外,如果网页是经典的 ASP,请对其进行标记以扩展您的潜在回答者列表,
  • 很抱歉,我不是 DBA,我对这些东西很陌生...你能澄清一下你说我应该做什么吗?
  • 这是 VB.NET 吗?还是经典的 ASP?看起来它对我来说不是 ASP.NET。
  • 这很容易受到 sql 注入攻击 :(
  • 这是 Classic ASP,CDO 是使用 Classic ASP 发送电子邮件的标准方式。 SmtpClient 类是 .net 的,所以在 ASP.net 中重写整个脚本你不能转换它。

标签: sql vbscript asp-classic html-email


【解决方案1】:

MS 可能不再支持 CDO - 就像 Classic ASP 本身一样,但它仍然有效。我会研究在您的 ASP 应用程序中设置一个脚本以使用 CDO 发送邮件。这样您就可以更好地控制任何 SQL 注入威胁并在一个地方管理整个过程。

这是一个示例 CDO 邮件脚本。

<%
'* Declare mailobject variables.
Dim validEmail, email_to, objCDOMail, objConf

Sub SetMailObject()

  '* set up CDO config
  Set objConf=Server.CreateObject("CDO.Configuration")
  objConf.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
  objConf.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "mysmtp.server.com"
  objConf.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1
  objConf.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusername") = "myusername"
  objConf.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "mypassword"
  objConf.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
  objConf.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = False
  objConf.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 60
  objConf.Fields.Update

  ' Create an instance of the NewMail object.
  Set objCDOMail = Server.CreateObject("CDO.Message")
  Set objCDOMail.Configuration=objConf
End Sub

Sub sendLoginEmail(email_to)

  '* Call Sub to set mail object settings
  SetMailObject()

  '* Set the mail objects
  objCDOMail.From = "myadmin@mydomain.com"
  objCDOMail.To = email_to
  objCDOMail.Bcc = ""
  objCDOMail.Subject = "My mail subject"
  objCDOMail.TextBody = "My email body"

  '* Send the message
  objCDOMail.Send

  '* Set the object to nothing
  Set objCDOMail = Nothing

End Sub

If Request("loginemail") <> "" Then
   validEmail = Request("loginemail")
   '* strongly suggest to perform some cleansing and validation of the email here
   Call sendLoginEmail(validEmail)
End If
%>

【讨论】:

    猜你喜欢
    • 2010-09-24
    • 1970-01-01
    • 2010-11-13
    • 2011-09-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多