Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    Senior Coder Spudhead's Avatar
    Join Date
    Jun 2002
    Location
    London, UK
    Posts
    1,856
    Thanks
    8
    Thanked 110 Times in 109 Posts

    Authenticated email using CDO.Message

    The short version:
    When I create an email using CDO.Message (and not using the "Local Pickup Directory" method), is there any way I can "see" the actual thing that's being created? Like, if I'm having problems with a SQL statement I can write out the statement that's actually being fired at the server. But when I create an email I can only set the configuration fields and have to hope that the...thing.... sent to the SMTP server has got the right headers, etc.

    The long version:
    I'm trying to relay authenticated emails from our IIS6 server (a dedicated machine we rent off a well-known UK hosting company). I can send unauthenticated emails fine, as long as I set the 'from' address to one that is associated with a domain hosted on the machine.

    I want to be able to set the 'from' address to anything; my understanding is that I must therefore allow the server to relay messages and that, since I don't want to open it up to spammers, I must use authenticated relaying.

    The hosting is managed via an online control panel called "Matrix". As far as I can see, the website-administration part of this is simply an interface onto IIS: I create a new website entry in Matrix and can then go into IIS on the server and see the new website listed. Great.

    But the email part is not: the "Default SMTP Server" under IIS is empty (although it is running ) and a "Matrix SMTP server" is running as a service on the machine. The Matrix control panel has a dropdown under "SMTP Open Relay Status" with 3 options: "Disabled", "Enabled (Local domains only)" and "Enabled (Authenticated)". Usually it's set to local domains only, and I can send email from any domain that is hosted on the machine.

    There is very little documentation available from the hosting company on the workings of this SMTP server. Their tech support is useless; the problem "must be with my code".

    The code I'm using is below. I always set the relay status to "Enabled (Authenticated)" before I try testing it.

    The problem:
    Emails aren't being sent. A delivery failure notification is generated in C:\Inetpub\mailroot\Badmail, telling me it had a "551 Bad Recipient" error. The recipient address is 100% normal and valid and working.

    Code:
    <%
    CONST SMTPSendUsing		= 2	'	Send using Port (SMTP over the network)
    CONST SMTPServer		= "mailserver.our-domain.com"
    CONST SMTPServerPort		= 26
    CONST SMTPAuthenticate		= 1	'	1=Basic, 2=NTLM (Windows Authentication), 0=none
    CONST SMTPUserName		= "valid-mailbox@our-domain.com"
    CONST SMTPUserPass		= "password"
    CONST SMTPUseSSL		= false
    CONST SMTPConnectionTimeout	= 10 'seconds
    
    dim sSubject, sEmail, sMailBody, sFrom, sReadReceipt, sMsg
    sSubject	= "Test"
    sEmail		= "recipient@their-domain.com"
    sMailBody	= "Test body"
    sFrom		= "address@domain-we-dont-host.com"
    sReadReceipt	= true
    sMsg		= ""
    
    On Error Resume Next
    
    dim oMail, oConfig, oConfigFields
    set oMail		= Server.CreateObject("CDO.Message")
    set oConfig		= Server.CreateObject("CDO.Configuration")
    set oConfigFields	= oConfig.Fields
    
    with oConfigFields
    	.Item("http://schemas.microsoft.com/cdo/configuration/sendusing")		= SMTPSendUsing
    	.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver")		= SMTPServer
    	.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport")		= SMTPServerPort
    	.Item("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate")	= SMTPAuthenticate
    	.Item("http://schemas.microsoft.com/cdo/configuration/sendusername")		= SMTPUserName
    	.Item("http://schemas.microsoft.com/cdo/configuration/sendpassword")		= SMTPUserPass
    	.Update
    end with
    oMail.Configuration = oConfig
    
    oMail.Subject	= sSubject
    oMail.From	= sFrom
    oMail.To	= sEmail
    oMail.HTMLBody	= sMailBody
    oMail.TextBody	= "You have received a HTML email from " & sFrom & " but your email client can only accept text emails."
    
    oMail.Send
    set oMail=nothing
    
    sMsg = "Message Sent"
    
    if Err.Number <> 0 then sMsg = "ERROR: " & Err.Description
    
    %>
    I've tried using different values for SMTPAuthenticate, and I've tried using a windows user account login, rather than just a valid mailbox on the machine. No luck.

    Apologies for the lengthy post. Thank you for getting this far, and for any suggestions, up to and including "give up and go to the pub".
    Last edited by Spudhead; 09-13-2007 at 05:41 PM.

  • #2
    Senior Coder BarrMan's Avatar
    Join Date
    Feb 2005
    Location
    Israel.
    Posts
    1,644
    Thanks
    69
    Thanked 83 Times in 82 Posts
    You can always use BCC.
    The problem:
    Have you tried sending your mail through a regular server and not localhost?
    Last edited by BarrMan; 09-14-2007 at 04:43 PM.

  • #3
    Senior Coder Spudhead's Avatar
    Join Date
    Jun 2002
    Location
    London, UK
    Posts
    1,856
    Thanks
    8
    Thanked 110 Times in 109 Posts
    Huh? I don't follow. Use BCC? I want to set the From address. And I'm not sending from localhost. Well, I'm sending from a mailserver that's running on the same machine as the code but I always referer to it by its full domain URL, never as "localhost".


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •