Connecting Tech Pros Worldwide Forums | Help | Site Map

Sending mails using ASP

Newbie
 
Join Date: Nov 2008
Posts: 18
#1: Feb 2 '09
Hi all,

I am tryin to send a mail using ASP through my webpage.
There are many web-pages that give code which looks like given below...

Quote:
<%
Set myMail=CreateObject("CDO.Message")
myMail.Subject="Sending email with CDO"
myMail.From="mymail@mydomain.com"
myMail.To="someone@somedomain.com"
myMail.TextBody="This is a message."
myMail.Send
set myMail=nothing
%>
from the code its obvious that we need to modify it with our mail IDs for verification purposes. I did so but still it doesnt seem to work...are their any SMTP related issues in this ? Please guide me to make this code work.

One question more....how can we send e-mails from any mail-id without requiring its password ?

Member
 
Join Date: Oct 2007
Location: Cape Girardeau
Posts: 53
#2: Feb 4 '09

re: Sending mails using ASP


I believe that you need to set the configuration for the email to be sent.

here is the example

Expand|Select|Wrap|Line Numbers
  1.  Set objMail = Server.CreateObject("CDO.Message")
  2.  Set objConfig = Server.CreateObject("CDO.Configuration")
  3.  
  4.   objConfig.Fields("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
  5.   objConfig.Fields("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "*****"  'here you will be using the smpt server address
  6.   objConfig.Fields("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 4   ' here you will use the smpt server port number 
  7.   objConfig.Fields.Update
  8.   set objMail.Configuration = objConfig
  9.  
  10.   objMail.Subject="Test"
  11.   objMail.From="example@example.com"
  12.   objMail.To="example@example.com"  
  13.   objMail.HTMLBody=" This is a test "
  14.   objMail.Send
  15.  
  16.  
  17.  
first you need to find the smtp address, and the port number that is being used by email client on the server. Usually you can get help from the hosting company on this they can provide you with the smtp address and the port info.
jhardman's Avatar
Moderator
 
Join Date: Jan 2007
Location: logan, utah
Posts: 2,690
#3: Feb 4 '09

re: Sending mails using ASP


Quote:

Originally Posted by theaj View Post

One question more....how can we send e-mails from any mail-id without requiring its password ?

If there was an easy way to send emails it would be exploited by spammers. Unfortunately, that makes it more difficult for legitimate programmers to do their job.

You may rest assured that I would delete any post that explained a way to send from any email ID without requiring authentication, and I would ban any user offering that code.

Jared, moderator
classic ASP forum, Bytes.com
Newbie
 
Join Date: Nov 2008
Posts: 18
#4: Feb 5 '09

re: Sending mails using ASP


Quote:

Originally Posted by jhardman View Post

If there was an easy way to send emails it would be exploited by spammers. Unfortunately, that makes it more difficult for legitimate programmers to do their job.

You may rest assured that I would delete any post that explained a way to send from any email ID without requiring authentication, and I would ban any user offering that code.

Jared, moderator
classic ASP forum, Bytes.com


Excuse me...but you took me in the wrong sense...my question was more like...

"I wonder how can this be possible to send emails without requiring any password ?"

As this code showed, I thought this code does so. I too know that this is not legal and ethical too.
Newbie
 
Join Date: Nov 2008
Posts: 18
#5: Feb 5 '09

re: Sending mails using ASP


Quote:

Originally Posted by semomaniz View Post

I believe that you need to set the configuration for the email to be sent.

here is the example

Expand|Select|Wrap|Line Numbers
  1.  Set objMail = Server.CreateObject("CDO.Message")
  2.  Set objConfig = Server.CreateObject("CDO.Configuration")
  3.  
  4.   objConfig.Fields("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
  5.   objConfig.Fields("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "*****"  'here you will be using the smpt server address
  6.   objConfig.Fields("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 4   ' here you will use the smpt server port number 
  7.   objConfig.Fields.Update
  8.   set objMail.Configuration = objConfig
  9.  
  10.   objMail.Subject="Test"
  11.   objMail.From="example@example.com"
  12.   objMail.To="example@example.com"  
  13.   objMail.HTMLBody=" This is a test "
  14.   objMail.Send
  15.  
  16.  
  17.  
first you need to find the smtp address, and the port number that is being used by email client on the server. Usually you can get help from the hosting company on this they can provide you with the smtp address and the port info.


Thanks for the response semomaniz.

Please tell me what kind of this mail will be ? I am asking so because, would it not require a permission (a password in this case) from the sender ?

(Moderators please don't see this question as if I am seeking any such hacking kind of code. All I want to know is the mechanism of sending mails using ASP)

And what you meant by Hosting Company ?
jhardman's Avatar
Moderator
 
Join Date: Jan 2007
Location: logan, utah
Posts: 2,690
#6: Feb 5 '09

re: Sending mails using ASP


Quote:

Originally Posted by theaj View Post

Thanks for the response semomaniz.

Please tell me what kind of this mail will be ? I am asking so because, would it not require a permission (a password in this case) from the sender ?

(Moderators please don't see this question as if I am seeking any such hacking kind of code. All I want to know is the mechanism of sending mails using ASP)

And what you meant by Hosting Company ?

Are you hosting this website from your own PC? If not, the people who maintain the server should let you know the SMTP address and port number you can use. This is also part of the configuration (I don't think I saw those lines in the code semomaniz posted.

When you send the mail it is sent first to the email server at a particular address and communicated at a particular port (this might be considered the first line of security, if you don't know that basic info you won't get any farther). The mail server should then verify that the sending email address has permission to send from that server. I'm not sure if anything else is checked, but certainly there is not usually a need to enter a password.

Jared
Member
 
Join Date: Oct 2007
Location: Cape Girardeau
Posts: 53
#7: Feb 5 '09

re: Sending mails using ASP


you don't require password for the email, for the code that i have posted. The mail server authenticates you automatically. The from email address should be the address that is already created on you mail server. if the email address does not exist in the mail server you wont be able to send the email.
Newbie
 
Join Date: Nov 2008
Posts: 18
#8: Feb 10 '09

re: Sending mails using ASP


Quote:

Originally Posted by semomaniz View Post

you don't require password for the email, for the code that i have posted. The mail server authenticates you automatically. The from email address should be the address that is already created on you mail server. if the email address does not exist in the mail server you wont be able to send the email.


does that mean I can't test my code unless I host it on an actual website ?
If it is so,is there any way I can test wheather I am getting the desired functionality before actually hosting this facility on website ?

(bear with me if im totally out of context...im new to ASP)
jhardman's Avatar
Moderator
 
Join Date: Jan 2007
Location: logan, utah
Posts: 2,690
#9: Feb 10 '09

re: Sending mails using ASP


Quote:

Originally Posted by theaj View Post

does that mean I can't test my code unless I host it on an actual website ?
If it is so,is there any way I can test wheather I am getting the desired functionality before actually hosting this facility on website ?

(bear with me if im totally out of context...im new to ASP)

You need an SMTP server in order to test, and most places that would host a website provide SMTP services as well. You can turn on SMTP from your own IIS, but that's beyond my specialty.

Jared
Reply