Jump to content

controll e-mail senderID asp.net


Recommended Posts

I have made a contact form on a web-site, where one of the fields to fill out is the senders e-mail adress.

When I try sending a mail to my self on a hotmail acount, the Hotmail always puts the email on the Junk E-mail folder. It stands that the sender-Id cannot be controlled..

This is the code that I use..

<%@ Import Namespace="System.Web.Mail" %>

<script runat="Server">
Sub Button_Click( s As Object, e As EventArgs )
SmtpMail.Send( _
mailfrom.Text, _
mailto.Text, _
mailsubject.Text, _
mailbody.Text )
End Sub
</Script>

<html>
<head><title>SendMail.aspx</title></head>
<body>

<h1>Send Mail:</h1>
<form runat="Server">

<b>From:</b>
<br>
<asp:TextBox
ID="mailfrom"
Columns="50"
Runat="Server" />
<p>
<b>To:</b>
<br>
<asp:TextBox
ID="mailto"
Columns="50"
Runat="Server" />
<p>
<b>Subject:</b>
<br>
<asp:TextBox
ID="mailsubject"
Columns="50"
Runat="Server" />
<p>
<b>Body:</b>
<br>
<asp:TextBox
ID="mailbody"
TextMode="Multiline"
Columns="50"
Rows="10"
Runat="Server" />
<p>
<asp:Button
Text="Send!"
OnClick="Button_Click"
Runat="Server" />
</form>

</body>
</html>

Link to comment
Share on other sites

  • 3 months later...

I do not think the problem is in your code, as you said the mail is delivered at hotmail, so technicaly its working ;-)

It is more likely your mail is seen as 'potential spam' because the sender address (domain name eg microsoft.com) is not the same address your mailserver ( servername = mywebsite.com).

To circumvent having your mail end up in the spamfilters configure script to send the mail with a mail address that does reside on your own webserver.

You need to be carefull with scripts like these though, people may abuse them to send spam and if that happens you may get blacklisted. The best use for scripts like these in my opinion is to only send mail from the form to your own address.

:)

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...