View Full Version : mail send through cdosys component of asp
This the code which i am using for sending the mail from web server. Still the mails are not going what is the problem. Is there any setting problem any clue....
<%
Set myMail=CreateObject("CDO.Message")
myMail.Subject="Sending email with CDO"
myMail.From="sam.salkar@sam.salkar"
myMail.To="sam.salkar@gmail.com"
myMail.TextBody="This is a message."
myMail.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/sendusing")=2
'Name or IP of remote SMTP server
myMail.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpserver") _
="127.0.0.1"
myMail.Configuration.Fields.Update
myMail.Send
set myMail=nothing
%>
hinch
12-12-2005, 10:42 AM
try implementing the mail script from my signature if that doesnt work then at a guess its the smtp setup its self.
if you get a transport error then the mail component cdo or cdonts isnt installed
michaelwall
12-12-2005, 03:13 PM
do you get an error message?
BarrMan
12-12-2005, 03:37 PM
hinch is right, there are no error message for these, it just won't send the email... when you're using localhost, you need to install the email feature to use it.
if you're not sure, if the code is fine or not, check it on a server and see if it's the computer's problem or the code's problem.
-2147220977 (0x8004020F) this is the COM Error Number
Also let me know where I can check the cdo component?
BarrMan
12-16-2005, 08:07 AM
Set mymail = Server.createobject("cdo.message")
still it is giving the same error
hinch
12-16-2005, 12:41 PM
turn off friendly http error messages implement my 500.100 page so you can get some proper debug info and then post the error results
this is the error message aftern turning off friendly http error messages error '8004020f'
one more thing is if i am using the same code with same server it is working properly but if I am using remote server to send mail it is giving this error.
is there any other code to send mail from remote machine.
any help will be greatfull....
sending the code again
Set objConfig = Server.CreateObject("CDO.Configuration")
With objConfig
.Fields("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2 'CdoSendUsingPort
.Fields("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "serverip"
.Fields("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
'.Fields("http://schemas.microsoft.com/cdo/configuration/sendusername") = "username"
'.Fields("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "password"
.Fields("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1
'.Fields(cdoSMTPServerPickupDirectory) = "\\servername\testmail$\pickup"
'.Fields(cdoFlushBuffersOnWrite) = True
.Fields.Update
End With
Set objMsg = Server.CreateObject("CDO.Message")
With objMsg
'associate configuration object with message object
Set .Configuration = objConfig
.From = "mailid"
.Subject = "subject "
.To = "mailid"
.HTMLBody = "message"
.Send
End With
Set objMsg = Nothing
set objConfig = Nothing
the only thing which i am changing is removeing comment's for username and password and changing ip address
TheShaner
01-03-2006, 05:58 PM
I think the problem you're having (since you say it works when you run it on the same server as opposed to remotely) is the IP you provide. The IP: 127.0.0.1 can only be recognized locally. That IP is a local IP to the network. You need the global IP that the server can be reached from outside the network (what the rest of the world would see as your IP).
If that isn't the problem, then I would check out the link below and try fixing anything along those guidelines they give you.
http://www.aspfaq.com/show.asp?id=2305
-Shane
No that is not the problem because the IP which I am using for remote is not local IP it is global IP that the server can be reached from outside the network
TheShaner
01-04-2006, 03:55 PM
If you can get the script to work on the server and not remotely, then it would seem that it's a problem with the IP you're providing. I say this because it cannot be your authentication if it works locally. It cannot be the script since it works locally. Maybe your server and/or mail server has some permission issues possibly with allowing remote access. Just to clarify, the IP 127.0.0.1 cannot be accessed remotely. So hopefully you have another IP you use for access to your mail server. If you do and you're sure that's the IP to connect remotely, then I'd look into your IIS configuration and permissions and your mail configuration and permissions.
-Shane
the two things i am not sure is the value which I am passing to field
sendusing
smtpauthenticate
can u just verify that I tried it but just if u knwo anything or
or
If u have any code which is running for remote smtp server and working successfully
vBulletin® v3.8.2, Copyright ©2000-2010, Jelsoft Enterprises Ltd.