Logo 
Search:

Asp.net Forum

Ask Question   UnAnswered
Home » Forum » Asp.net       RSS Feeds

SMTP mail problem

  Asked By: Egidius    Date: Aug 05    Category: Asp.net    Views: 1269
  

I'm trying to get a smtp mail output from a form:
Here is the script code.........


<!-- #include virtual="global/lib.asp" -->
<p>KOMOTION Order system v1
<p><a href="/index.asp">Item list</a>
<p><%
IF Request("confirm") <> "" THEN
varUpdate = "UPDATE tb_OS_Order SET" & _
" stName='" & Replace(Request("stName"), "'", "''") & "'," & vbCrLf & _
" stAdd1='" & Replace(Request("stAdd1"), "'", "''") & "'," & vbCrLf & _
" atAdd2='" & Replace(Request("stAdd2"), "'", "''") & "'," & vbCrLf & _
" stAdd3='" & Replace(Request("stAdd3"), "'", "''") & "'," & vbCrLf & _
" stAdd4='" & Replace(Request("stAdd4"), "'", "''") & "'," & vbCrLf & _
" stPostcode='" & Replace(Request("stPostcode"), "'", "''") & "'," & vbCrLf & _
" stEmail='" & Replace(Request("stEmail"), "'", "''") & "'," & vbCrLf & _
" stTel='" & Replace(Request("stTel"), "'", "''") & "'," & vbCrLf & _
" stFax='" & Replace(Request("stFax"), "'", "''") & "'" & vbCrLf & _
" WHERE inOrderID=" & Session("orderID")
Response.Write Replace(varUpdate, vbCrLf, "<br>")
kom_conn.Execute(varUpdate)
%><p>Thankyou for placing an order...
<p>Your details have been sent to a Komotion rep.
<%
Set objMail = Server.CreateObject("CDONTS.NewMail")
objMail.From = Request("email")
objMail.Subject = "KOMOTION - New Online Order"
objMail.To = "twisted_vibe@..."
objMail.Body = "new order - nuff said. http://www.komotion.org/admin"
objMail.Send
set objMail = nothing
ELSE
%><p><table cellpadding=6 cellspacing=0 border=1 width=450>
<tr><form name="details" action="/completeOrder.asp" method="post">
<input type="hidden" name="confirm" value="1">
<td>Name</td>
<td><input name="stName" value="" size=35 maxlength="200"></td>
</tr><tr>
<td>Address 1</td>
<td><input name="stAdd1" value="" size=35 maxlength="100"></td>
</tr><tr>
<td>Address 2</td>
<td><input name="stAdd2" value="" size=35 maxlength="100"></td>
</tr><tr>
<td>Address 3</td>
<td><input name="stAdd3" value="" size=35 maxlength="100"></td>
</tr><tr>
<td>Address 4</td>
<td><input name="stAdd4" value="" size=35 maxlength="100"></td>
</tr><tr>
<td>Postcode</td>
<td><input name="stPostcode" value="" size=35 maxlength="10"></td>
</tr><tr>
<td>Emai1</td>
<td><input name="stEmail" value="" size=35 maxlength="255"></td>
</tr><tr>
<td>Tel</td>
<td><input name="stTel" value="" size=35 maxlength="20"></td>
</tr><tr>
<td>Fax</td>
<td><input name="stFax" value="" size=35 maxlength="20"></td>
</tr>
</table>
<p><input type="submit" value=" confirm order ">
</form><%
END IF
%>
<p> 


And this is the error.........

Microsoft VBScript runtime error '800a0046'
Permission denied
/completeOrder.asp, line 34

Share: 

 

4 Answers Found

 
Answer #1    Answered By: Amir Shaikh     Answered On: Aug 05

This is an asp  Classic problem  not an ASP.net problem.

 
Answer #2    Answered By: Abriana Rossi     Answered On: Aug 05

I am having a problem  when I am trying to send an email from my
local host. Here is there error  message I get: The server rejected
one or more recipient addresses. The server response was: 550 5.7.1
Unable to relay for yosefzachbryan@.... I can change the
email address as much as I want but I still get the same error.
Below is the code  I am using. Please let me know what I can do to
fix this problem. Here is the code I am using:


namespace Ww3live
{
using System;
using System.Data;
using System.Data.SqlClient;
using System.Drawing;
using System.Web;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using System.Web.Mail;

/// <summary>
/// Summary description for RegisterUser.
/// </summary>
public class RegisterUser : System.Web.UI.UserControl
{
#region variables
protected System.Web.UI.WebControls.Label
lblUserName;
protected System.Web.UI.WebControls.TextBox
txtUserName;
protected System.Web.UI.WebControls.TextBox txtEmail;
protected System.Web.UI.WebControls.Label lblPass;
protected System.Web.UI.WebControls.TextBox txtPass;
protected System.Web.UI.WebControls.Label
lblVerifyPass;
protected System.Web.UI.WebControls.TextBox
txtVerifyPass;
protected System.Web.UI.WebControls.Label
lblBirthYear;
protected System.Web.UI.WebControls.Label
lblBirthDay;
protected System.Web.UI.WebControls.Label
lblBirthMonth;
protected System.Web.UI.WebControls.Label lblEmail;
protected System.Web.UI.WebControls.DropDownList
ddlYear;
protected System.Web.UI.WebControls.DropDownList
ddlDay;
protected System.Web.UI.WebControls.DropDownList
ddlMonth;
protected System.Web.UI.WebControls.Button
btnRegister;
protected
System.Web.UI.WebControls.RequiredFieldValidator rfvUserName;
protected
System.Web.UI.WebControls.RequiredFieldValidator rfvEmail;
protected
System.Web.UI.WebControls.RegularExpressionValidator revEmail;
protected
System.Web.UI.WebControls.ValidationSummary vsError;
protected
System.Web.UI.WebControls.RequiredFieldValidator rfvPass;
protected
System.Web.UI.WebControls.RequiredFieldValidator rfvVerifyPass;
int year;
protected System.Web.UI.WebControls.CompareValidator
cvPass;
protected
System.Web.UI.WebControls.RegularExpressionValidator revUserName;
protected
System.Web.UI.WebControls.RegularExpressionValidator revPass;
protected
System.Web.UI.WebControls.RegularExpressionValidator revVerifyPass;
protected System.Web.UI.WebControls.Label lblMessage;
protected System.Data.SqlClient.SqlCommand
sqlSelectCommand1;
protected System.Data.SqlClient.SqlCommand
sqlInsertCommand1;
protected System.Data.SqlClient.SqlCommand
sqlUpdateCommand1;
protected System.Data.SqlClient.SqlCommand
sqlDeleteCommand1;
protected System.Data.SqlClient.SqlConnection
sqlConnection1;
protected System.Data.SqlClient.SqlDataAdapter
sqlDataAdapter1;
string test;
#endregion

private void Page_Load(object sender,
System.EventArgs e)
{
// Put user code to initialize the page here
FillYears();
FillDays();
FillMonths();
}

#region Web Form Designer generated code
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: This call is required by the
ASP.NET Web Form Designer.
//
InitializeComponent();
base.OnInit(e);
}

/// <summary>
/// Required method for Designer
support - do not modify
/// the contents of this method with the
code editor.
/// </summary>
private void InitializeComponent()
{
this.sqlSelectCommand1 = new
System.Data.SqlClient.SqlCommand();
this.sqlInsertCommand1 = new
System.Data.SqlClient.SqlCommand();
this.sqlUpdateCommand1 = new
System.Data.SqlClient.SqlCommand();
this.sqlDeleteCommand1 = new
System.Data.SqlClient.SqlCommand();
this.sqlConnection1 = new
System.Data.SqlClient.SqlConnection();
this.sqlDataAdapter1 = new
System.Data.SqlClient.SqlDataAdapter();
this.btnRegister.Click += new
System.EventHandler(this.btnRegister_Click);
//
// sqlSelectCommand1
//
this.sqlSelectCommand1.CommandText = "SELECT
PlayerId, PlayerName, PlayerEmail, PlayerPass, PlayerBirth FROM
tblPlayer";
this.sqlSelectCommand1.Connection =
this.sqlConnection1;
//
// sqlInsertCommand1
//
this.sqlInsertCommand1.CommandText = "INSERT
INTO tblPlayer(PlayerName, PlayerEmail, PlayerPass, PlayerBirth)
VALUES (@" +
"PlayerName, @PlayerEmail,
@PlayerPass, @PlayerBirth); SELECT PlayerId, PlayerNam" +
"e, PlayerEmail, PlayerPass,
PlayerBirth FROM tblPlayer WHERE (PlayerId = @@IDENT" +
"ITY)";
this.sqlInsertCommand1.Connection =
this.sqlConnection1;
this.sqlInsertCommand1.Parameters.Add(new
System.Data.SqlClient.SqlParameter("@PlayerName",
System.Data.SqlDbType.VarChar, 50, "PlayerName"));
this.sqlInsertCommand1.Parameters.Add(new
System.Data.SqlClient.SqlParameter("@PlayerEmail",
System.Data.SqlDbType.VarChar, 100, "PlayerEmail"));
this.sqlInsertCommand1.Parameters.Add(new
System.Data.SqlClient.SqlParameter("@PlayerPass",
System.Data.SqlDbType.VarChar, 50, "PlayerPass"));
this.sqlInsertCommand1.Parameters.Add(new
System.Data.SqlClient.SqlParameter("@PlayerBirth",
System.Data.SqlDbType.DateTime, 4, "PlayerBirth"));
//
// sqlUpdateCommand1
//
this.sqlUpdateCommand1.CommandText =
@"UPDATE tblPlayer SET PlayerName = @PlayerName, PlayerEmail =
@PlayerEmail, PlayerPass = @PlayerPass, PlayerBirth = @PlayerBirth
WHERE (PlayerId = @Original_PlayerId) AND (PlayerBirth =
@Original_PlayerBirth) AND (PlayerEmail = @Original_PlayerEmail) AND
(PlayerName = @Original_PlayerName) AND (PlayerPass =
@Original_PlayerPass); SELECT PlayerId, PlayerName, PlayerEmail,
PlayerPass, PlayerBirth FROM tblPlayer WHERE (PlayerId = @PlayerId)";
this.sqlUpdateCommand1.Connection =
this.sqlConnection1;
this.sqlUpdateCommand1.Parameters.Add(new
System.Data.SqlClient.SqlParameter("@PlayerName",
System.Data.SqlDbType.VarChar, 50, "PlayerName"));
this.sqlUpdateCommand1.Parameters.Add(new
System.Data.SqlClient.SqlParameter("@PlayerEmail",
System.Data.SqlDbType.VarChar, 100, "PlayerEmail"));
this.sqlUpdateCommand1.Parameters.Add(new
System.Data.SqlClient.SqlParameter("@PlayerPass",
System.Data.SqlDbType.VarChar, 50, "PlayerPass"));
this.sqlUpdateCommand1.Parameters.Add(new
System.Data.SqlClient.SqlParameter("@PlayerBirth",
System.Data.SqlDbType.DateTime, 4, "PlayerBirth"));
this.sqlUpdateCommand1.Parameters.Add(new
System.Data.SqlClient.SqlParameter("@Original_PlayerId",
System.Data.SqlDbType.Int, 4, System.Data.ParameterDirection.Input,
false, ((System.Byte)(0)), ((System.Byte)(0)), "PlayerId",
System.Data.DataRowVersion.Original, null));
this.sqlUpdateCommand1.Parameters.Add(new
System.Data.SqlClient.SqlParameter("@Original_PlayerBirth",
System.Data.SqlDbType.DateTime, 4,
System.Data.ParameterDirection.Input, false, ((System.Byte)(0)),
((System.Byte)(0)), "PlayerBirth",
System.Data.DataRowVersion.Original, null));
this.sqlUpdateCommand1.Parameters.Add(new
System.Data.SqlClient.SqlParameter("@Original_PlayerEmail",
System.Data.SqlDbType.VarChar, 100,
System.Data.ParameterDirection.Input, false, ((System.Byte)(0)),
((System.Byte)(0)), "PlayerEmail",
System.Data.DataRowVersion.Original, null));
this.sqlUpdateCommand1.Parameters.Add(new
System.Data.SqlClient.SqlParameter("@Original_PlayerName",
System.Data.SqlDbType.VarChar, 50,
System.Data.ParameterDirection.Input, false, ((System.Byte)(0)),
((System.Byte)(0)), "PlayerName",
System.Data.DataRowVersion.Original, null));
this.sqlUpdateCommand1.Parameters.Add(new
System.Data.SqlClient.SqlParameter("@Original_PlayerPass",
System.Data.SqlDbType.VarChar, 50,
System.Data.ParameterDirection.Input, false, ((System.Byte)(0)),
((System.Byte)(0)), "PlayerPass",
System.Data.DataRowVersion.Original, null));
this.sqlUpdateCommand1.Parameters.Add(new
System.Data.SqlClient.SqlParameter("@PlayerId",
System.Data.SqlDbType.Int, 4, "PlayerId"));
//
// sqlDeleteCommand1
//
this.sqlDeleteCommand1.CommandText = "DELETE
FROM tblPlayer WHERE (PlayerId = @Original_PlayerId) AND
(PlayerBirth = @O" +
"riginal_PlayerBirth) AND
(PlayerEmail = @Original_PlayerEmail) AND (PlayerName =" +
" @Original_PlayerName) AND
(PlayerPass = @Original_PlayerPass)";
this.sqlDeleteCommand1.Connection =
this.sqlConnection1;
this.sqlDeleteCommand1.Parameters.Add(new
System.Data.SqlClient.SqlParameter("@Original_PlayerId",
System.Data.SqlDbType.Int, 4, System.Data.ParameterDirection.Input,
false, ((System.Byte)(0)), ((System.Byte)(0)), "PlayerId",
System.Data.DataRowVersion.Original, null));
this.sqlDeleteCommand1.Parameters.Add(new
System.Data.SqlClient.SqlParameter("@Original_PlayerBirth",
System.Data.SqlDbType.DateTime, 4,
System.Data.ParameterDirection.Input, false, ((System.Byte)(0)),
((System.Byte)(0)), "PlayerBirth",
System.Data.DataRowVersion.Original, null));
this.sqlDeleteCommand1.Parameters.Add(new
System.Data.SqlClient.SqlParameter("@Original_PlayerEmail",
System.Data.SqlDbType.VarChar, 100,
System.Data.ParameterDirection.Input, false, ((System.Byte)(0)),
((System.Byte)(0)), "PlayerEmail",
System.Data.DataRowVersion.Original, null));
this.sqlDeleteCommand1.Parameters.Add(new
System.Data.SqlClient.SqlParameter("@Original_PlayerName",
System.Data.SqlDbType.VarChar, 50,
System.Data.ParameterDirection.Input, false, ((System.Byte)(0)),
((System.Byte)(0)), "PlayerName",
System.Data.DataRowVersion.Original, null));
this.sqlDeleteCommand1.Parameters.Add(new
System.Data.SqlClient.SqlParameter("@Original_PlayerPass",
System.Data.SqlDbType.VarChar, 50,
System.Data.ParameterDirection.Input, false, ((System.Byte)(0)),
((System.Byte)(0)), "PlayerPass",
System.Data.DataRowVersion.Original, null));
//
// sqlConnection1
//
this.sqlConnection1.ConnectionString
= "workstation id=HOME;packet size=4096;integrated
security=SSPI;data source=HOME;pe" +
"rsist security info=False;initial
catalog=ww3live";
//
// sqlDataAdapter1
//
this.sqlDataAdapter1.DeleteCommand =
this.sqlDeleteCommand1;
this.sqlDataAdapter1.InsertCommand =
this.sqlInsertCommand1;
this.sqlDataAdapter1.SelectCommand =
this.sqlSelectCommand1;
this.sqlDataAdapter1.TableMappings.AddRange
(new System.Data.Common.DataTableMapping[] {



new System.Data.Common.DataTableMapping
("Table", "tblPlayer", new System.Data.Common.DataColumnMapping[] {






new
System.Data.Common.DataColumnMapping("PlayerId", "PlayerId"),






new
System.Data.Common.DataColumnMapping("PlayerName", "PlayerName"),






new
System.Data.Common.DataColumnMapping("PlayerEmail", "PlayerEmail"),






new
System.Data.Common.DataColumnMapping("PlayerPass", "PlayerPass"),






new
System.Data.Common.DataColumnMapping
("PlayerBirth", "PlayerBirth")})});
this.sqlDataAdapter1.UpdateCommand =
this.sqlUpdateCommand1;
this.Load += new System.EventHandler
(this.Page_Load);

}
#endregion

public int GetYear()
{
year = int.Parse
(System.DateTime.Now.Year.ToString());
return year;
}

public void FillYears()
{
int temp = GetYear() - 100;
for(int i = temp; i <= GetYear(); i++)
{
ddlYear.Items.Add(i.ToString());
ddlYear.DataBind();
}
}

public void FillDays()
{
for(int i = 1; i <= 31; i++)
{
ddlDay.Items.Add(i.ToString());
ddlDay.DataBind();
}
}

public void FillMonths()
{
for(int i = 1; i <= 12; i++)
{
ddlMonth.Items.Add(i.ToString());
ddlMonth.DataBind();
}
}

private void btnRegister_Click(object sender,
System.EventArgs e)
{
test = string.Empty;

SqlCommand uName = new SqlCommand();
uName.Connection = sqlConnection1;
uName.CommandType =
CommandType.StoredProcedure;
uName.CommandText = "sp_FindEmail";
uName.Parameters.Add(new SqlParameter
("@Email", SqlDbType.VarChar, 100));
uName.Parameters["@Email"].Value =
txtEmail.Text;
sqlConnection1.Open();

try
{
test = uName.ExecuteScalar().ToString
();
lblMessage.Text = "This email
already exists, please choice another email address.";
}
catch(NullReferenceException nre)
{
string error = nre.Message;
test = string.Empty;
}

if(test == string.Empty)
{
SqlCommand cmd = new SqlCommand();
cmd.Connection = sqlConnection1;
cmd.CommandType =
CommandType.StoredProcedure;
cmd.CommandText = "sp_FindUser";
cmd.Parameters.Add(new SqlParameter
("@uName", SqlDbType.VarChar, 50));
cmd.Parameters["@uName"].Value =
txtUserName.Text;

try
{
test = cmd.ExecuteScalar
().ToString();
lblMessage.Text = "This
player name already exists, please choice another name.";
}
catch(NullReferenceException nre)
{
string error = nre.Message;
test = string.Empty;
}

sqlConnection1.Close();

if(test == string.Empty)
{
RegisterPlayer();
}
}
}

public void RegisterPlayer()
{
lblMessage.Text = string.Empty;
string playerBirth =
ddlMonth.SelectedItem.Text + "/" +
ddlDay.SelectedItem.Text + "/" +
ddlYear.SelectedItem.Text;
register player = new register
(txtUserName.Text, txtEmail.Text,
txtPass.Text, playerBirth);
SqlCommand cmd = new SqlCommand();
cmd.Connection = sqlConnection1;
cmd.CommandType =
CommandType.StoredProcedure;
cmd.CommandText = "sp_AddUser";

cmd.Parameters.Add(new SqlParameter
("@pName", SqlDbType.VarChar, 50));
cmd.Parameters["@pName"].Value =
player.UserName;
cmd.Parameters.Add(new SqlParameter
("@pEmail", SqlDbType.VarChar, 100));
cmd.Parameters["@pEmail"].Value =
player.Email;
cmd.Parameters.Add(new SqlParameter
("@pPass", SqlDbType.VarChar, 50));
cmd.Parameters["@pPass"].Value = player.Pass;
cmd.Parameters.Add(new SqlParameter
("@pBirth", SqlDbType.SmallDateTime));
cmd.Parameters["@pBirth"].Value =
player.BirthDay;
sqlConnection1.Open();

try
{
cmd.ExecuteNonQuery();

SendEmail();
lblMessage.Text = player.UserName
+ " is now registered under " +
player.Email + ". Please
wait for the verification letter" +
" to activate your account.";
}
catch(System.Exception err)
{
Response.Write(err.Message);
}
finally
{
ClearFields();
sqlConnection1.Close();
}
}

public void ClearFields()
{
txtEmail.Text = "";
txtPass.Text = "";
txtUserName.Text = "";
txtVerifyPass.Text = "";
ddlDay.SelectedIndex = 0;
ddlMonth.SelectedIndex = 0;
ddlYear.SelectedIndex = 0;
}

public void SendEmail()
{
Server.ScriptTimeout = 1000;
Response.Flush();

MailMessage mail  = new MailMessage();
SmtpMail.SmtpServer = "localhost";
mail.To = txtEmail.Text;
mail.From = "admin@...";
mail.Subject = "WW3Live.com Activation
Validation";
mail.Body = "Welcome to WW3Live.com!<br>" +
"Your User Name is: " + txtUserName.Text
+ "<br><br>" +
"Your Password is: " + txtPass.Text
+ "<br><br>" +
"To activate your account, please click
the " +
"following link.";
mail.BodyEncoding =
System.Text.Encoding.GetEncoding( "GB2312" );

try
{
SmtpMail.Send(mail.From, mail.To,
mail.Subject, mail.Body);
Response.Write("The Mail has been
sent to: ");
Response.Write(mail.To);
Response.Write(mail.Body);
}
catch(System.Exception msg)
{
Response.Write(msg.Message);
}
Response.Flush();
}
}
}




 
Answer #3    Answered By: Mario Ryan     Answered On: Aug 05

Not sure about the code  as I'm code dyslexic, this looks a relay issue and
not a code issue.
you may need to go into Internet Information services and set  the virtual
SMTP access properties, there is a relay restrictions section that you can
set.
Your network may not allow relaying at all?

I have a Web Objects system  that allows you to set a username and password
for a mail  account so it doesn't use relaying, I'd be interested to know if
and how you could code that in aspx. so it wouldn't use relaying?

 
Answer #4    Answered By: Garry Sanchez     Answered On: Aug 05

It appears that your server requires either POP3 authentication before
sending an email or SMTP authentication during the sending process. I don't
see any authentication being done in your script. (SendEmail())

You need to login to the mail  server in this routine before you will be
allowed to generate emails outside your hosted domain.

I think this is done by simply specifying a username and password to use by
the call to the SMTP server but I cannot remember.

The other option would be to allow all mail from localhost but that opens up
a can or worms (or SPAM).

 
Didn't find what you were looking for? Find more on SMTP mail problem Or get search suggestion and latest updates.




Tagged: