Solved

Script to send confirmation e-mail not working

Posted on 2007-03-29
6
1,060 Views
Last Modified: 2012-05-05
I am using the following script which I got off the internet to send a confirmation e-mail to clients after they have filled in my form.  The problem is that though the script report no errors the e-mails are not received and may well not be sent.  Is there someway I can tell whether the e-mails are at least sent?  What could the problem possibly be?

Const cdoSendUsingPickup = 1
Const cdoSendUsingPort = 2
Const cdoSendUsingExchange = 3

Const cdoAnonymous = 0
Const cdoBasic = 1
Const cdoNTLM = 2

'Sends an email To aTo email address, with Subject And TextBody.
'The email is In text format.
'Lets you specify BCC adresses, Attachments, smtp server And Sender email address

  on error resume Next

  Dim Message 'As New CDO.Message '(New - For VBA)
 
  'Create CDO message object
  Set Message = CreateObject("CDO.Message")

  'Set configuration fields.
  With Message.Configuration.Fields
    'Original sender email address
    .Item("http://schemas.microsoft.com/cdo/configuration/sendemailaddress") = "myemail@yahoo.com"

    'SMTP settings - without authentication, using standard port 25 on host smtp
    .Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = cdoSendUsingPort
    .Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
    .Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "smtp.btl.net"

    'SMTP Authentication
    .Item("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = cdoAnonymous

    .Update
  End With

  'Set other message fields.
  With Message
    'From, To, Subject And Body are required.
    .From = "myemail@yahoo.com"
    .To = "myemail@yahoo.com"
    .Subject = "Land Registry Application re Parcel " + request.form("PARCELNO") + "in Reg. Section " + request.form("REG_SECTION")

    'Set TextBody property If you want To send the email As plain text
    .TextBody = "This is to confirm receipt of your application(s)."

    'Set HTMLBody  property If you want To send the email As an HTML formatted
    '.HTMLBody = TextBody

    'Blind copy And attachments are optional.
    'If Len(BCC)>0 Then .BCC = BCC
    'If Len(Files)>0 Then .AddAttachment Files
   
    'Send the email
       response.write("before sending")
    .Send
    response.write("after sending")
  End With

  'Returns zero If succesfull. Error code otherwise
  SendMailByCDO = Err.Number
0
Comment
Question by:desmondg
6 Comments
 

Author Comment

by:desmondg
ID: 18820429
I put a response.write err.description and gets the error
"The transport failed to connect to the server."  Any ideas anyone.
0
 
LVL 6

Expert Comment

by:DocGyver
ID: 18867299
Next thing I'd try is to attemt to telnet to port 25 on the smtp.btl.net machine from the machine where the code has to run.  If you get a response then send the QUIT command to disconnect.  Doing so will at least see if you can connect and issue a simple command.

If that works then you should try to send an email manually. To do this telnet to port 25 again and issue the following commands changing for appropriate email addresses in case it works:

telnet smtp.btl.net 25
HELO localhost
MAIL FROM: my@mydomain.tld
RCPT TO: guytosendto@his.domain.tld
DATA
put some things to send here
and finish with a line with a single dot (.) on a line by itself
.
QUIT

You may not have to issue the QUIT depending on how the server is configured.  Let me know what results you get with that.  Then we can diagnose the CDO stuff in your VB code.
0
 

Author Comment

by:desmondg
ID: 19190006
After we changed our DSL provider I was surprised to find that e-mails were filling my in-box from this application.  

I have tried DocGyver's experiments since and was able to send e-mails using telnet.
0
 
LVL 1

Accepted Solution

by:
Computer101 earned 0 total points
ID: 20634014
PAQed with points refunded (250)

Computer101
EE Admin
0
 

Expert Comment

by:Trindaz
ID: 21843392
I know points have been refunded already but...

Is your SMTP server configured to allow for anonymous sending of emails? This might explain why email sending works from your email client, but not from the script, and would explain why you can't connect to the server.

The line specifying anonymous sending copied below (change to what I'm not exactly sure)
.Item("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = cdoAnonymous

Open in new window

0

Featured Post

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

This tutorial will discuss the log-in process using WhizBase. In this article I assume you already know HTML. I will write the code using WhizBase Server Pages, so you need to know some basics in WBSP (you might look at some of my other articles abo…
It is becoming increasingly popular to have a front-page slider on a web site. Nearly every TV website,  magazine or online news has one on their site, and even some e-commerce sites have one. Today you can use sliders with Joomla, WordPress or …
Learn the basics of if, else, and elif statements in Python 2.7. Use "if" statements to test a specified condition.: The structure of an if statement is as follows: (CODE) Use "else" statements to allow the execution of an alternative, if the …
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

911 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now