Solved

Script to send confirmation e-mail not working

Posted on 2007-03-29
6
1,063 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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
How does Redux fit into React? 3 84
Selecting Right Partition 6 69
AWK: add from two digits (the month) within date string dd/mm/yyyy 2 18
BATCH to EXE Converter 2 39
One of the typical problems I have experienced is when you have to move a web server from one hosting site to another. You normally prepare all on the new host, transfer the site, change DNS and cross your fingers hoping all will be ok on new server…
In threads here at EE, each comment has a unique Identifier (ID). It is easy to get the full path for an ID via the right-click context menu. However, we often want to post a short link within a thread rather than the full link. This article shows a…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)

830 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