Ciao ragazzi,
vorrei fare una cosa banalissima, ovvero inviare una il risultato di una form compilata su di un indirizzo mail...
Ho scaricato una miriade di script ma mi sfugge qualche passaggio e non riesco a farli funzionare!:incazz2:
In uno di questi script, quello che vi riporto integralmente qui sotto, viene chiesto come vedrete una mail di destinazione (la mail presso cui arriveranno i messaggi, mentre le restanti parti della form, compreso l'indirizzo del mittente, vengono inseriti dall'utente che tenta l'invio. Io mi sono chiesto: ma come cavolo fa lo script ad inoltrare una form verso un indirizzo E-mail se non si connette ad un server SMTP previa autenticazione??!!!!
Ecco lo script... non da nessun errore, ma non funziona!!!!!:dipser:
<%@ Language = "VBScript" %>
<%
Select Case Request.Querystring("Action")
Case "Send"
on error resume next
'Set variables
Dim BackURL
Dim strName
Dim strEmail
Dim strSubject
Dim strMessage
Dim strUserIP
Dim strToEmail
Dim daCdoMail
'Replace this email with your real email id
strToEmail = "[email protected]"
BackURL = Request.ServerVariables("HTTP_REFERER")
strName = Request.form("Name")
strEmail = Request.form("Email")
strSubject = Request.form("Subject")
strMessage = Request.form("Message")
strUserIP = Request.ServerVariables("REMOTE_ADDR")
'Create Mail Object
Set daCdoMail = CreateObject("CDONTS.NewMail")
daCdoMail.To = strToEmail
daCdoMail.From = strEmail
daCdoMail.Subject = strSubject
daCdoMail.Body = "<font size=""small"">This message was sent by " & strName & " at " & Now() & ". </font><br><br>" & strMessage & _
"<hr height=""1""><font size=""2""><b>ASP Contact Form Script </b>Powered by <b><font color=""#FF0000"">DigitalArakan</font></b><br>" & _
"</font><a href=""http://www.digitalarakan.net"">http://www.digitalarakan.net</font></a>"
'You can change the mail body format setting below
'0 = HTML, 1 = TEXT
daCdoMail.BodyFormat = 0
'You can change the mail format setting below
'0 = HTML, 1 = TEXT
daCdoMail.MailFormat = 0
'Set Server Side Validation to make sure we got both sender and recipient email Id to send email
If strToEmail = "" OR strEmail = "" Then
Session("msg") = "Sender Email or Resipient Email is blank. This message can not be sent. Please try again"
Response.redirect (BackURL)
Else
'Now send email to the address you specified at line no. 16
daCdoMail.Send
End If
'Destroy mail object
Set daCdoMail = Nothing
'Create result text in a Sesion
Session("MsgSent") = "Your email with subject [<b>" & strSubject & "</b>] has been sent. Thank you for writing to us."
'Redirect and show the result
Response.redirect (BackURL)
End Select
%>
<html>
<head>
<meta http-equiv="Content-Language" content="en-us">
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>ASP Contact Form Version 1 Powered by DigitalArakan</title>
<meta name="Naing Win - DigitalArakan - http://www.digitalarakan.net" content="Author">
<SCRIPT language=javascript>
function check()
{
if (document.myform.Name.value.length==0)
{
alert("Please enter your Name");
document.myform.Name.focus();
}
else if(document.myform.Email.value.length==0 || document.myform.Email.value.indexOf("@")==-1 || document.myform.Email.value.indexOf(".")==-1 || document.myform.Email.value.indexOf(" ")==0)
{
alert("You must enter a Valid Email ID")
document.myform.Email.focus();
}
else if (document.myform.Subject[document.myform.Subject.selectedIndex].value.length==0)
{
alert("Please select a Subject");
document.myform.Subject.focus();
}
else if(document.myform.Message.value==0)
{
alert("Message field cannot be left empty");
document.myform.Message.focus();
}
else
{
document.myform.submit()
}
}
</SCRIPT>
<style>
<!--
h3 { font-family: Tahoma; font-size: 14pt; color: #003399; font-weight: bold }
td { font-family: Tahoma; font-size: 11pt }
-->
</style>
</head>
<body>
<%If Session("msgSent") = "" Then%>
<table cellSpacing="1" border="0" bordercolor="#111111" id="table1" width="100%">
<form action="Contact.asp?Action=Send" method="post" name="myform">
<tr>
<td align="right" colspan="2">
<h3 align="left">Contact Form</h3>
</td>
</tr>
<tr>
<td colspan="2">
If you want to contact us for any questions or suggestions, then please fill the form correctly and send it to us by hitting the
'Send Message' button.</td>
</tr>
<%If Session("msg") <> "" Then%>
<tr>
<td colspan="2">
<font size="1" color="#FF0000"><%=Session("msg")%></font> </td>
</tr>
<%End If%>
<tr>
<td colspan="2">
</td>
</tr>
<tr>
<td class="nortex">Your Name:</td>
<td class="nortex">
<input maxLength="25" size="37" name="Name" value="<%= Request.form("Name") %>"></td></tr>
<tr>
<td class="nortex">Your Email:</span></td>
<td class="nortex">
<input maxLength="25" size="37" name="Email" value="<%= Request.form("Email") %>"></td></tr>
<tr>
<td class="nortex">Subject:</td>
<td class="nortex"><select name="Subject">
<option selected>Select Subject</option>
<option value="Question">Question</option>
<option value="Suggestion">Suggestion</option>
<option value="Broken Link" Links>Broken Links</option>
<option value="None of the above" of the above>None of the above</option></select> </td></tr>
<tr>
<td class="nortex" valign="top">Your Message:</td>
<td class="nortex">
<textarea name="Message" rows="12" cols="48"><%= Request.form("Message") %></textarea></td></tr>
<tr>
<td class="nortex"> </td>
<td class="nortex">
<input onclick="check()" type="button" value="Send Message" name="sendmessage" style="float: center; font-weight:bold"></td></tr>
<tr>
<td class="nortex" colspan="2"> </td>
</tr>
<tr>
<td class="nortex" colspan="2">
<%
'DO NOT REMOVE THIS LINE
Response.write "<p></p><p align=""center""><font size=""1""><b>ASP Contact Form Script </b>Powered by <b><font color=""#FF0000"">DigitalArakan</font></b><br>" & _
"</font><a href=""http://www.digitalarakan.net"" target=""_blank""><font size=""1"">http://www.digitalarakan.net</font></a>"
%>
</td>
</tr>
</form>
</table>
<%Else%>
<table cellSpacing="1" border="0" bordercolor="#111111" id="table2" width="100%">
<tr>
<td align="right">
<h3 align="left">Message Sent</h3>
</td>
</tr>
<tr>
<td>
<font size="1" color="#FF0000"><%=Session("MsgSent")%></font> </td>
</tr>
<tr>
<td>
<%
'DO NOT REMOVE THIS LINE
Response.write "<p> </p> <p><p align=""center""><font size=""1""><b>ASP Contact Form Script </b>Powered by <b><font color=""#FF0000"">DigitalArakan</font></b><br>" & _
"</font><a href=""http://www.digitalarakan.net"" target=""_blank""><font size=""1"">http://www.digitalarakan.net</font></a>"
%>
</td></tr>
</table>
<%End If
'Destroy session variables
Session("MsgSent") = ""
Session("msg") = ""
%>
</body>
</html>
vorrei fare una cosa banalissima, ovvero inviare una il risultato di una form compilata su di un indirizzo mail...
Ho scaricato una miriade di script ma mi sfugge qualche passaggio e non riesco a farli funzionare!:incazz2:
In uno di questi script, quello che vi riporto integralmente qui sotto, viene chiesto come vedrete una mail di destinazione (la mail presso cui arriveranno i messaggi, mentre le restanti parti della form, compreso l'indirizzo del mittente, vengono inseriti dall'utente che tenta l'invio. Io mi sono chiesto: ma come cavolo fa lo script ad inoltrare una form verso un indirizzo E-mail se non si connette ad un server SMTP previa autenticazione??!!!!
Ecco lo script... non da nessun errore, ma non funziona!!!!!:dipser:
<%@ Language = "VBScript" %>
<%
Select Case Request.Querystring("Action")
Case "Send"
on error resume next
'Set variables
Dim BackURL
Dim strName
Dim strEmail
Dim strSubject
Dim strMessage
Dim strUserIP
Dim strToEmail
Dim daCdoMail
'Replace this email with your real email id
strToEmail = "[email protected]"
BackURL = Request.ServerVariables("HTTP_REFERER")
strName = Request.form("Name")
strEmail = Request.form("Email")
strSubject = Request.form("Subject")
strMessage = Request.form("Message")
strUserIP = Request.ServerVariables("REMOTE_ADDR")
'Create Mail Object
Set daCdoMail = CreateObject("CDONTS.NewMail")
daCdoMail.To = strToEmail
daCdoMail.From = strEmail
daCdoMail.Subject = strSubject
daCdoMail.Body = "<font size=""small"">This message was sent by " & strName & " at " & Now() & ". </font><br><br>" & strMessage & _
"<hr height=""1""><font size=""2""><b>ASP Contact Form Script </b>Powered by <b><font color=""#FF0000"">DigitalArakan</font></b><br>" & _
"</font><a href=""http://www.digitalarakan.net"">http://www.digitalarakan.net</font></a>"
'You can change the mail body format setting below
'0 = HTML, 1 = TEXT
daCdoMail.BodyFormat = 0
'You can change the mail format setting below
'0 = HTML, 1 = TEXT
daCdoMail.MailFormat = 0
'Set Server Side Validation to make sure we got both sender and recipient email Id to send email
If strToEmail = "" OR strEmail = "" Then
Session("msg") = "Sender Email or Resipient Email is blank. This message can not be sent. Please try again"
Response.redirect (BackURL)
Else
'Now send email to the address you specified at line no. 16
daCdoMail.Send
End If
'Destroy mail object
Set daCdoMail = Nothing
'Create result text in a Sesion
Session("MsgSent") = "Your email with subject [<b>" & strSubject & "</b>] has been sent. Thank you for writing to us."
'Redirect and show the result
Response.redirect (BackURL)
End Select
%>
<html>
<head>
<meta http-equiv="Content-Language" content="en-us">
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>ASP Contact Form Version 1 Powered by DigitalArakan</title>
<meta name="Naing Win - DigitalArakan - http://www.digitalarakan.net" content="Author">
<SCRIPT language=javascript>
function check()
{
if (document.myform.Name.value.length==0)
{
alert("Please enter your Name");
document.myform.Name.focus();
}
else if(document.myform.Email.value.length==0 || document.myform.Email.value.indexOf("@")==-1 || document.myform.Email.value.indexOf(".")==-1 || document.myform.Email.value.indexOf(" ")==0)
{
alert("You must enter a Valid Email ID")
document.myform.Email.focus();
}
else if (document.myform.Subject[document.myform.Subject.selectedIndex].value.length==0)
{
alert("Please select a Subject");
document.myform.Subject.focus();
}
else if(document.myform.Message.value==0)
{
alert("Message field cannot be left empty");
document.myform.Message.focus();
}
else
{
document.myform.submit()
}
}
</SCRIPT>
<style>
<!--
h3 { font-family: Tahoma; font-size: 14pt; color: #003399; font-weight: bold }
td { font-family: Tahoma; font-size: 11pt }
-->
</style>
</head>
<body>
<%If Session("msgSent") = "" Then%>
<table cellSpacing="1" border="0" bordercolor="#111111" id="table1" width="100%">
<form action="Contact.asp?Action=Send" method="post" name="myform">
<tr>
<td align="right" colspan="2">
<h3 align="left">Contact Form</h3>
</td>
</tr>
<tr>
<td colspan="2">
If you want to contact us for any questions or suggestions, then please fill the form correctly and send it to us by hitting the
'Send Message' button.</td>
</tr>
<%If Session("msg") <> "" Then%>
<tr>
<td colspan="2">
<font size="1" color="#FF0000"><%=Session("msg")%></font> </td>
</tr>
<%End If%>
<tr>
<td colspan="2">
</td>
</tr>
<tr>
<td class="nortex">Your Name:</td>
<td class="nortex">
<input maxLength="25" size="37" name="Name" value="<%= Request.form("Name") %>"></td></tr>
<tr>
<td class="nortex">Your Email:</span></td>
<td class="nortex">
<input maxLength="25" size="37" name="Email" value="<%= Request.form("Email") %>"></td></tr>
<tr>
<td class="nortex">Subject:</td>
<td class="nortex"><select name="Subject">
<option selected>Select Subject</option>
<option value="Question">Question</option>
<option value="Suggestion">Suggestion</option>
<option value="Broken Link" Links>Broken Links</option>
<option value="None of the above" of the above>None of the above</option></select> </td></tr>
<tr>
<td class="nortex" valign="top">Your Message:</td>
<td class="nortex">
<textarea name="Message" rows="12" cols="48"><%= Request.form("Message") %></textarea></td></tr>
<tr>
<td class="nortex"> </td>
<td class="nortex">
<input onclick="check()" type="button" value="Send Message" name="sendmessage" style="float: center; font-weight:bold"></td></tr>
<tr>
<td class="nortex" colspan="2"> </td>
</tr>
<tr>
<td class="nortex" colspan="2">
<%
'DO NOT REMOVE THIS LINE
Response.write "<p></p><p align=""center""><font size=""1""><b>ASP Contact Form Script </b>Powered by <b><font color=""#FF0000"">DigitalArakan</font></b><br>" & _
"</font><a href=""http://www.digitalarakan.net"" target=""_blank""><font size=""1"">http://www.digitalarakan.net</font></a>"
%>
</td>
</tr>
</form>
</table>
<%Else%>
<table cellSpacing="1" border="0" bordercolor="#111111" id="table2" width="100%">
<tr>
<td align="right">
<h3 align="left">Message Sent</h3>
</td>
</tr>
<tr>
<td>
<font size="1" color="#FF0000"><%=Session("MsgSent")%></font> </td>
</tr>
<tr>
<td>
<%
'DO NOT REMOVE THIS LINE
Response.write "<p> </p> <p><p align=""center""><font size=""1""><b>ASP Contact Form Script </b>Powered by <b><font color=""#FF0000"">DigitalArakan</font></b><br>" & _
"</font><a href=""http://www.digitalarakan.net"" target=""_blank""><font size=""1"">http://www.digitalarakan.net</font></a>"
%>
</td></tr>
</table>
<%End If
'Destroy session variables
Session("MsgSent") = ""
Session("msg") = ""
%>
</body>
</html>