Forum Moderators: open

Message Too Old, No Replies

emailing out of asp

         

Blelisa

8:32 pm on Mar 8, 2005 (gmt 0)

10+ Year Member



Does anyone see where I am going wro ng with emailing out of asp. I am not getting any errors but when I test it I am not getting an email. Thanks for the help.

<%
Dim intCounter, intDecimal, strPassword

For intCounter = 1 To 6
Randomize
intDecimal = Int((26 * Rnd) + 1) + 64

strPassword = strPassword & Chr(intDecimal)

Next

set connection=Server.CreateObject("ADODB.Connection")
connection.ConnectionString="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" &_
server.MapPath("data/hemicustreg.mdb")
connection.Open

sql="INSERT INTO customer ([CmpName], [Address], [City], [State], [Zip], [Number], [Contact], [email], [System], [Pwrd], [Username])"
sql=sql & "VALUES"
sql=sql & "('" & Request.Form("cmpname") & "',"
sql=sql & "'" & Request.Form("address") & "',"
sql=sql & "'" & Request.Form("city") & "',"
sql=sql & "'" & Request.Form("state") & "',"
sql=sql & "'" & Request.Form("zip") & "',"
sql=sql & "'" & Request.Form("number") & "',"
sql=sql & "'" & Request.Form("contact") & "',"
sql=sql & "'" & Request.Form("email") & "',"
sql=sql & "'" & Request.Form("system") & "',"
sql=sql & "'" & strpassword & "',"
sql=sql & "'" & Request.Form("username") & "')"

connection.Execute(sql)

if err<>0 then
Response.Write(Err.Description)
else
response.redirect("tyreg.html")
end if
connection.close

Set Mail=Server.CreateObject("CDONTS.NewMail")
Mail.To=Request.Form("email")
Mail.From="lblendowski@magneforcess.com"
Mail.Subject="Just testing my script"
Mail.Body="Your password is" & strPassword
Mail.Send
Set Mail=nothing
%>

CaseyRyan

8:47 pm on Mar 8, 2005 (gmt 0)

10+ Year Member



In order to use the CDO object this way, you would have to have an SMTP server running on the same server the webserver is on.

If the SMTP server isn't configured correctly, then it may be doing this.
If it's a MS SMTP server you can check in the BadMail, Drop, Queue directories under the MailRoot (defaultly C:\Inetpub\MailRoot).If you find your mail in any of those, then then there's problems with the SMTP server or relay you're using.

ISPs can block traffic from an SMTP server too. I know that lots of Cable Modem companies will block any SMTP relays in their IP blocks to prevent spammers.

Spam engines can block emails that are spoofed. Meaning that if the IP address you're email is coming from isn't the same as the one that the magneforcess.com is authoritative for, a spam engine might see that as spam.

-=casey=-

dotme

2:36 pm on Mar 9, 2005 (gmt 0)

10+ Year Member



Lisa, adding to CaseyRyan's post, this may be an IIS setting. Assuming your server is W2K or NT4, if the SMTP service isn't running your mail will be in the C:\inetpub\mailroot\pickup folder.

If it is running and your mail is all in the C:\inetpub\mailroot\badmail folder, then you have other issues. If the server is sending to your mailserver (seperate system) within the company, for example, the firewall will create problems. Firewalls often don't allow traffic to leave and u-turn to come back inside. There are some pretty easy remedies for these kind of situations. If you can't get it working, let us know.

Blelisa

6:12 pm on Mar 9, 2005 (gmt 0)

10+ Year Member



Hey guys,

Just got off the line with my web hoster, he thoroughly went through the server my site is sitting on and all is configured correctly. He also said that he knows of several other sites on this server and contacted them and they are not having any problems with email from an asp page. Any other thoughts?

Blelisa

8:41 pm on Mar 9, 2005 (gmt 0)

10+ Year Member



The plot thickens.....
Here are two asp pages I wrote. One works great! the other does not work. I have been starting at these two for over an hour to try to find the discrepency. I am now seeing double.
This is the working code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<%@ language="VBScript" %>
<html>
<head>
<title>first asp</title>
<% Response.Buffer = True %>
</head>
<body>

<%

Dim intCounter, intDecimal, strPassword

For intCounter = 1 To 6
Randomize
intDecimal = Int((26 * Rnd) + 1) + 64

strPassword = strPassword & Chr(intDecimal)

Next

Response.Write "Random Password = " & strPassword

Set connection = Server.CreateObject("ADODB.Connection")
connection.ConnectionString="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" &_
server.MapPath("data\testing.mdb")
connection.Open

sql="INSERT INTO member (username, email, random)"
sql=sql & "VALUES"
sql=sql & "('" & Request.Form("username") & "',"
sql=sql & "'" & Request.Form("email") & "',"
sql=sql & "'" & strpassword & "')"

response.write(sql)

on error resume next
connection.Execute sql
if err<>0 then
Response.Write(Err.Description)
else
response.write("Record was updated!")
end if
connection.close

Set Mail=Server.CreateObject("CDONTS.NewMail")
Mail.to=request.form("email")
Mail.From="lblendowski@magneforcess.com"
Mail.Subject="Just testing my script"
Mail.Body="Your password is" & strPassword
Mail.Send
Set Mail=nothing
%>
</body>
</html>


This is the non-working code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<%@ language="VBScript" %>
<html>
<head>
<title>first asp</title>
<% Response.Buffer = True %>
</head>
<body>

<%

Dim intCounter, intDecimal, strPassword

For intCounter = 1 To 6
Randomize
intDecimal = Int((26 * Rnd) + 1) + 64

strPassword = strPassword & Chr(intDecimal)

Next

set connection=Server.CreateObject("ADODB.Connection")
connection.ConnectionString="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" &_
server.MapPath("data/hemicustreg.mdb")
connection.Open

sql="INSERT INTO customer ([CmpName], [Address], [City], [State], [Zip], [Number], [Contact], [email], [System], [Pwrd], [Username])"
sql=sql & "VALUES"
sql=sql & "('" & Request.Form("cmpname") & "',"
sql=sql & "'" & Request.Form("address") & "',"
sql=sql & "'" & Request.Form("city") & "',"
sql=sql & "'" & Request.Form("state") & "',"
sql=sql & "'" & Request.Form("zip") & "',"
sql=sql & "'" & Request.Form("number") & "',"
sql=sql & "'" & Request.Form("contact") & "',"
sql=sql & "'" & Request.Form("email") & "',"
sql=sql & "'" & Request.Form("system") & "',"
sql=sql & "'" & strpassword & "',"
sql=sql & "'" & Request.Form("username") & "')"

connection.Execute(sql)

on error resume next
connection.Execute sql
if err<>0 then
Response.Write(Err.Description)
else
response.redirect("tyreg.html")
end if
connection.close

Set Mail=Server.CreateObject("CDONTS.NewMail")
Mail.to=request.form("email")
Mail.From="lblendowski@magneforcess.com"
Mail.Subject="Just testing my script"
Mail.Body="Your password is" & strPassword
Mail.Send
Set Mail=nothing
%>
</body>
</html>
%>

CaseyRyan

9:09 pm on Mar 9, 2005 (gmt 0)

10+ Year Member



I think I found the problem.
If successful, you're redirecting before you send the mail.


if err<>0 then
Response.Write(Err.Description)
else
response.redirect("tyreg.html")
end if

I'd put the send mail code in the else statement before the redirect

-=casey=-

Blelisa

9:24 pm on Mar 9, 2005 (gmt 0)

10+ Year Member



Casey---

Thank you very much, you were right on the money! It works now!
Thanks Again!

~Lisa