View Full Version : CDONTS error concering FROM field
bostjank
01-10-2003, 10:54 AM
Hi!
There is a form on my site users can use to send recomendation to visit the site to their friends. I'm using CDONTS to send the recomendation and I would like that the user (his e-mail), who actually sent the recommendation, would be written in the FROM field.
This usually works fine, except in the cases where the user's e-mail address is not valid - then CDONTS don't send the recommendation.
I'm validating the syntax (structure) of the address, but this validation cannot discover other mistakes.
Let's say user enters 'name@yaho.com' instead of 'name@yahoo.com' - structure of e-mail address looks fine, but it's not valid, and mail won't be sent. I can write a procedure to trap this kind of errors for major e-mail providers, but certainly not all.
Do you have any solution to this problem (I wouldn't want my e-mail address in FROM field)?
Thanks,
Bostjan :thumbsup:
Mhtml
01-10-2003, 04:07 PM
That should not happen at all. Possibly the CDONTS component that you are using is not the ms version.
All it requires is an email address in the from variable, it doesn't have to be valid at all.
bostjank
01-10-2003, 04:24 PM
I know it shouldn't, but it does. I tested sending e-mail from an address where wrong server name (i.e. @yaho.com) was given and it wasn't sent. Then I tried to send it again (correct address @yahoo.com) and it was sent.
I noticed the problem on to servers where my sites are hosted. On server uses Windows NT and the other one uses Windows 2000. As I was told CDONTS are included with Windows - so I think they use MS version of CDONTS.
Is there any other option?
Bostjan
Mhtml
01-10-2003, 04:26 PM
Possibly it is a problem with your script. Can I see it, including any validation in js if any?
bostjank
01-10-2003, 05:00 PM
For validating I call the function PreveriPolje (I use this function for validationg all types of input). The result of the function is "" if everything is OK, otherwise its value contains the description of an error. If everything is OK, I send the e-mail through function PosljiMail.
<%
sMailFrom = Request.Form("txtMailFrom")
sMailTo = Request.Form("txtMailTo")
sCheckMailFrom = PreveriPolje("Your e-mail", sMailFrom, "mail", "")
sCheckMailTo = PreveriPolje("Your friend's e-mail", sMailTo, "mail", "")
If sCheckMailFrom <> "" Or sCheckMailTo <> "" Then
'there is an error
Else
sSend = PosljiMail(sMailFrom, sMailTo,sSubject,sBody1,sBody2,sBody3,"nic")
End If
%>
<%
Function PreveriPolje(strImePolja, strVrednost, strTip, strDolzina)
If strVrednost = "" Then
PreveriPolje = "Niste vnesli vrednosti v polje <b>" & strImePolja & "</b>.<br>"
Else
PreveriPolje = ""
If Not strDolzina = "" Then
strDolzina =CInt(strDolzina)
If Len(strVrednost) <> strDolzina Then
PreveriPolje = "Vrednost v polju <b>" & strImePolja & "</b> ni prave dolžine " & _
"(zahtevano število znakov: " & strDolzina & ").<br>"
End If
End If
'//vnesena vrednost je e-mail naslov
If strTip = "mail" Then
strNe = """'!#$%&/()=?*čČšŠžŽ,;:"
dMail = Len(strVrednost)
dNe = Len(strNe)
Nepravilno = "0"
NiPike = "1"
For i = 1 To dMail
strZnak1 = Mid(strVrednost, i, 1)
For j = 1 To dNe
strZnak2 = Mid(strNe, j, 1)
If strZnak1 = strZnak2 Then Nepravilno = "1"
Next
If strZnak1 = " " Then Nepravilno = "1"
If strZnak1 = "@" Then
If i = 1 Then Nepravilno = "1"
For k = i + 1 To dMail
strZnak2 = Mid(strVrednost, k, 1)
If strZnak2 = "@" Then Nepravilno = "1"
If strZnak2 = " " Then Nepravilno = "1"
If strZnak2 = "." Then
NiPike = "0"
If k = (i + 1) Or k = dMail Then Nepravilno = "1"
End If
Next
End If
Next
If Nepravilno = "1" Or NiPike = "1" Then
PreveriPolje = "V polje <b>" & strImePolja & "</b> niste vpisali pravilnega e-mail naslova (vnesli ste " & _
strVrednost & ").<br>"
End If
'//vnesena vrednost je število
Elseif strTip = "stevilo" Then
If IsNumeric(strVrednost) = False Then
PreveriPolje = "V polje <b>" & strImePolja & "</b> morate vpisali število (vnesli ste " & strVrednost & ").<br>"
End If
'//vnesena vrednost je datum
Elseif strTip = "datum" Then
If IsDate(strVrednost) = False Then
PreveriPolje = "V polje <b>" & strImePolja & "</b> morate vpisati datum (vnesli ste " & strVrednost & ").<br>"
End If
End If
End If
End Function
UvodNapaka = "<p>Podatki, ki ste jih hoteli dodati, so nepopolni:</p><blockquote>"
PopraviNapako = "</blockquote><p> </p><p><a href=""javascript:history.back();"">" & _
"Kliknite TUKAJ</a> za vrnitev na prejšnjo stran.</p>"
%>
<%
Function PosljiMail(MailFrom,MailTo,MailSubject,MailBody1,MailBody2,MailBody3,MailOblika)
Set strSendMail = Server.CreateObject("CDONTS.NewMail")
strSendMail.From = MailFrom
strSendMail.Subject = MailSubject
If MailOblika = "nic" Then
MailBody_z = "<html><head><meta http-equiv=""Content-Language"" content=""sl""> " & _
"<meta http-equiv=""Content-Type"" content=""text/html; charset=iso-8859-2"">" & _
"<style fprolloverstyle>A:hover {color: #CC0000; text-decoration: none}</style>" & _
"</head><body link=""#336699"" vlink=""#336699"" alink=""#336699""><font face=""Verdana"" size=""2"">"
MailBody_k = "</font></body></html>"
If Not MailBody1 = "" Then MailBody1_k = "<br><br>"
If Not MailBody3 = "" Then
MailBody3_z = "<font size=""1""><br><br><br>* * * * * * * * * * * * *<br>"
MailBody3_k = "<br><a href=" & PovezavaOdjava & "?MNaslov=" & MailTo & ">Povezava za odjavo</a></font>"
End If
MailBody = MailBody_z & MailBody1 & MailBody1_k & MailBody2 & MailBody3_z & _
MailBody3 & MailBody3_k & MailBody_k
strSendMail.BodyFormat = 0
strSendMail.MailFormat = 0
Else
MailBody = MailBody1
strSendMail.BodyFormat = 0
strSendMail.MailFormat = 0
End If
strSendMail.Body = MailBody
strSendMail.To = MailTo
strSendMail.Send
Set strSendMail = Nothing
End Function
%>
Mhtml
01-10-2003, 05:08 PM
It should work, sorry I couldn't help you.
whammy
01-10-2003, 11:56 PM
Have you tried a valid email address in the "From" field of your CDONTS email as I suggested above? What I mean, is an email address that resides on the same server that hosts the domain, if possible. For now, just try a plain email address, you can always change the "Name" it's coming from and still use a server email address, like:
"John Q. Smith" <feedback@mywebsitename.com>
I'm not sure why, but sometimes CDONTS fail otherwise...
Such as if your page is on:
http://www.mywebsitename.com
....try an email like: feedback@mywebsitename.com
that has been set up on the server.
If that doesn't work, I don't know what to tell you except maybe look at:
http://www.4guysfromrolla.com
in their "ASP FAQS" under email...
vBulletin® v3.8.2, Copyright ©2000-2012, Jelsoft Enterprises Ltd.