sendmail from windows server

admin

Administrator
Staff member
I am trying to build a webpage so users can submit a form to me, but I dont want it to open their default mail client. I want it to be a sendmail type of function right from the webpage.<br />
<br />
in other words;<br />
<br />
i dont want to us href:mailto<br />
<br />
i dont want to use 3rd party software<br />
<br />
<br />
does anyone know what I need to do for this?<br />
<br />
2003 server with the SMTP mailserver running<!--content-->I am also running 2K3 Server, but I do not know how to setup your request. 2K3 comes with the .Net Framework v 1.1, so why not have the results of your form store in a database. This can easily be done with the use of ASP.NET (ASPX) which 2K3 supports by default. If you know any of the visual languages (VB, VB.NET, C++, C#, etc) then you shold have no problem implementing this as ASPX allows the use of these languauges :)<!--content-->thanks anyways phill... I managed to find a something which you might be interested in too....<br />
<br />
<!-- m --><a class="postlink" href="http://www.asp101.com/samples/email_aspx.asp">http://www.asp101.com/samples/email_aspx.asp</a><!-- m --><br />
<br />
problem is... it sends mail to the user... I am looking to send mail from the users browser to me.<br />
<br />
any clue?<!--content-->Hmm, all you would have to do is change where the code uses the users email to yours. Should be nice and easy. Oh, btw, the mail wouldnt come from the users browser; its done server side, so it would come from your own server ;)<!--content--><%@ Page Language="VB" Debug="true"%> <br />
<%@ Import Namespace="System.Web.Mail" %><br />
<script language="VB" runat="server"> <br />
Sub btnGo_Click(sender As Object, e As EventArgs) <br />
Dim mail As New MailMessage <br />
mail.From = txtemail.text<br />
mail.To = "[email protected]"<br />
mail.Subject = txtsubject.text <br />
mail.Body = txtfrom.text & "<br>" & txtname.text & "<hr>" & txtbody.Text <br />
mail.BodyFormat = MailFormat.Html <br />
SmtpMail.Send(mail) <br />
response.Redirect("./thanks.aspx")<br />
End Sub <br />
</script> <br />
<br />
if the server does support asp.net, this usage of system.web.mail would be the easiest, you would need to have asp.net elelements with the names above to run this, I can give you what the body of the page would look like too if thats the problem, but yes as philly said this is run server side and your host not only has to support asp.net but have an smtp server to send the mail. You can take this one step further by swapping out elements on the mail page to tell the user what they sent or do it like a preview the message thing, or if you want to escape the post data you can pass the variables to another page with hidden inputs. (easier to move large data then the use of session, query string, or cookies)<!--content-->thanks guys, but...<br />
<br />
i am sort of a newbie... <br />
<br />
yes, i have SMTP server running: works fine, i can send an recieve, np<br />
yes, 2003 supports .net<br />
yes, I know its server side<br />
<br />
<br />
Peoffeo, how do i implement that script? I tried pasting it into my page and it gives me a error about my webconfig file, which I dont have. (probly the error?) what is the minimum I need to put into a web.config file to get this to work?<!--content-->PHP offers a much easier solution, as long as you know how to set up forms, & you have PHP support.<br />
<br />
Something like this might work...<br />
<form action="path/to/mail.php" action="post"><br />
<div><br />
<p><label for="name">Name:</label><input type="text" name="name" id="name" /></p> <br />
<p><label for="email">E-mail:</label><input type="text" name="email" id="email" /></p> <br />
<p><label>Message:</label><br /><textarea cols="5" rows="5" name="msg"></textarea></p><br />
<input type="submit" value="Send message" /><br />
<input type="reset" value="Start over" /><br />
</div><br />
</form> <?php<br />
/*Set these*/<br />
$your_email = "[email protected]";<br />
$subject = "What you want the subject to show up as";<br />
<br />
$name = $_POST["name"];<br />
$email = $_POST["email"];<br />
$msg = $_POST["msg"];<br />
<br />
$message = "Name: $name\nE-mail: $email\nMessage: $msg\n";<br />
<br />
if(mail($your_email, $subject, $message)) {<br />
echo "<h3>Sucess</h3><p>Your message has been sent.</p>";<br />
} else {<br />
echo "<h3>Error</h3><p>Your message has not been sent.</p>";<br />
}<br />
?> Putting the PHP code in a file called mail.php and replacing the action attribute on the form tag with the relative adress to mail.php<br />
<br />
Untested, by the way I just went by the PHP manual, I don't actually use this... if it works I may make it idiot-proof and then put it up on my site for people to use... ;)<!--content-->
 
Back
Top