|
-
Jan 6th, 2009, 12:58 AM
#1
Thread Starter
Hyperactive Member
Send email with textbox values
Hi i need to send a email to a constant mail id from my web page...
The user need to give his name, email, mobile no, country allt he details want to be sent... with the message...
From: Users email id
Subject: Name, Mobile no, Country
Message: Users comments from the message textbox
and i need the configuration details for the smtp server....
this is my first application in asp.net so let me have a clear idea on it...
Thanks in advance....
-
Jan 6th, 2009, 04:41 AM
#2
Re: Send email with textbox values
Sending email is reasonably easy with asp.net and is well described in this article.
As for the configuration details of the server you will need those details off someone who administers your SMTP server.
-
Jan 6th, 2009, 04:55 AM
#3
Thread Starter
Hyperactive Member
Re: Send email with textbox values
 Originally Posted by Fishcake
Sending email is reasonably easy with asp.net and is well described in this article.
As for the configuration details of the server you will need those details off someone who administers your SMTP server.
Hi this is my code,
is this correct...?
protected void btnSubmit_Click(object sender, EventArgs e)
{
MailMessage mail = new MailMessage();
mail.To = "[email protected]";
mail.From = txtemail.Text;
mail.Subject = txtname.Text;
mail.Body = txtmessage.Text;
SmtpMail.SmtpServer = "localhost";
SmtpMail.Send(mail);
}
by checking this i'll have a error on the SmtpMail.Send(mail);
tel me
Last edited by mendhak; Jan 6th, 2009 at 06:57 AM.
-
Jan 6th, 2009, 06:29 AM
#4
Junior Member
Re: Send email with textbox values
you need to actually fill in the "localhost" part, and for that it is very difficult to work with mail.From = txtEmail.Text, because different people use different smtp hosts.
The easiest way (and probably the only way?) is to bypass this using a dummy email adress.
For Example: For my school project I created a free G-Mail account [email protected].
(Why gmail? 1. because it's free, 2. because it uses a different port than port 25, unlike most other free hosts, and part 25 is sometimes blocked by some people's ISP)
Then in your code you say something like:
Code:
mail.From = "[email protected]"
smtpClient sendMail = new smtpClient("smtp.gmail.com","587")
SendMail.Credentials = New NetworkCredential("[email protected]", "yourpassword")
//you need this enabled, because gmail needs to verfiy you are the owner of the account
sendMail.Enablessl = true
sendMail.send(mail)
Forgive me if the syntax isn't 100% correct, I haven't got much time on hands right now.
Edit: to have the persons adress, you can always put it in the replyTo properte (mail.ReplayTo = txtEmail.text)
-
Jan 6th, 2009, 06:33 AM
#5
Re: Send email with textbox values
There's nothing that looks immediately wrong with your code.
What error do you get?
Is there an SMTP server running on the machine?
As you are not authenticating with the smtp server is it set up to act as an open relay for your web server?
NB. Best not to leave your email address in your post as it might get harvested for nasty spam.
-
Jan 6th, 2009, 06:38 AM
#6
Re: Send email with textbox values
 Originally Posted by Arsenal
you need to actually fill in the "localhost" part, and for that it is very difficult to work with mail.From = txtEmail.Text, because different people use different smtp hosts.
There's nothing wrong with that if your SMTP server is on the same machine as the webserver.
You can also allow any from address if the SMTP server is acting as a relay although admittedly this isn't usually desirable.
-
Jan 6th, 2009, 06:43 AM
#7
Junior Member
Re: Send email with textbox values
hmmm, i didn't know that, sorry, didn't mean to give anybody wrong advice!
I just spent hours and hours trying to get the simple email script to work a couple of days ago, and I found that using a dummy adress is simply the easiest way to do so.
But if people from other locations with different ISP's (and different SMTP server) send an email with this contact page, don't they need to use their smtp info? I can be very wrong here..
-
Jan 6th, 2009, 06:59 AM
#8
Re: Send email with textbox values
If a webserver is setup as an open relay it will send the email so it appears as though it came from the user specified even if it isn't from a known user.
This obviously is heaven for spammers though and the email may well be rejected by receiving mail servers as it will fail reverse DNS checks.
I'm certainly not recommending this setup and using gmail is a perfectly good solution.
EDIT: wikipedia link
-
Jan 6th, 2009, 07:01 AM
#9
Re: Send email with textbox values
However for a production website you'd most likely want emails to come from an address at the same domain as your website which is why you'd have your own SMTP server.
-
Jan 6th, 2009, 10:36 AM
#10
Re: Send email with textbox values
Your contact page will sit on your web server. This may be a company web server or a web host, presumably. You should, therefore have an SMTP server available to you already.
Perhaps you don't have one, but on a serious website, I wouldn't use a third party... it's just unprofessional.
-
Jan 7th, 2009, 12:14 AM
#11
Thread Starter
Hyperactive Member
Re: Send email with textbox values
 Originally Posted by mendhak
Your contact page will sit on your web server. This may be a company web server or a web host, presumably. You should, therefore have an SMTP server available to you already.
Perhaps you don't have one, but on a serious website, I wouldn't use a third party... it's just unprofessional. 
Hi guys thanks for your reply....
And my error is...
Http Exception was unhandled by user code.....
in the line of SmtpMail.Send(mail);....
and tel me where and how to configure the SMTP server....
Thanks to all...
-
Jan 7th, 2009, 06:20 AM
#12
Re: Send email with textbox values
You've set your SMTPServer as localhost. You haven't answered FC's/Arsenal's questions about your SMTP Server so I'm assuming you don't have one. If you're trying to use the GMail servers to send your emails you'll need to authenticate yourself first:
http://www.aspcode.net/Send-mail-fro...l-account.aspx
If that's not what you want, you'll need to explain it to us again.
-
Jan 7th, 2009, 08:09 AM
#13
Thread Starter
Hyperactive Member
Re: Send email with textbox values
 Originally Posted by mendhak
You've set your SMTPServer as localhost. You haven't answered FC's/Arsenal's questions about your SMTP Server so I'm assuming you don't have one. If you're trying to use the GMail servers to send your emails you'll need to authenticate yourself first:
http://www.aspcode.net/Send-mail-fro...l-account.aspx
If that's not what you want, you'll need to explain it to us again.
Hi Mendhak...
Thanks for your reply...
Ya i dont have a SMTP server....
But i like to test my application without a SMTP server as my own...
How to use it tel me....
-
Jan 7th, 2009, 08:18 AM
#14
Re: Send email with textbox values
-
Jan 8th, 2009, 03:46 AM
#15
Thread Starter
Hyperactive Member
Re: Send email with textbox values
 Originally Posted by mendhak
Hi Mendhak
I installed the IIS and configured the IIS.. but still i'm having the same error....
How to add the site to the IIS server and how to run it...
Thanks in advance....
-
Jan 8th, 2009, 03:52 AM
#16
Re: Send email with textbox values
In project properties, click on the web tab. In there, you should have an option that lets you specify the name of the virtual directory to use. There is a button there too that lets you create and configure the virtual directory in IIS, just to make things easier.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|