Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Testing SMTP email calls
Message
From
04/01/2024 15:24:51
 
 
To
04/01/2024 08:30:12
General information
Forum:
Visual FoxPro
Category:
Third party products
Miscellaneous
Thread ID:
01687494
Message ID:
01687496
Views:
55
>"Connection Rejected"
>if I remember correctly Office 365 requires oAuth 2.0 authentication and the port can't be 25 (maybe 465 or 587), TLS 1.2
>You could try to send mail with normal CDO with the same parameters (port 25, w/o authentication) just to see if it is possible or what error message this will return.
>

Thanks. For now, I'm trying this without Office 365 involved at all for simplicity. That's the reason for using the free online SMTP server. I tried setting smtpAuthMethod and that doesn't change anything (which makes sense, based on the docs).

I tried your CDO code below and that also fails to send with the error:

OLE IDispatch exception code 0 from CDO.Message.1: The transport failed to connect to the server.

That makes me think that maybe the note in the original error message about a firewall issue may be the key to solving this. (I hate this kind of stuff.)

Tamar

>This works for me (I don't receive any eMail though)
>
>SendCDOMail()
>
>
>FUNCTION SendCDOMail()
>SET STEP ON 
>    LOCAL loCDOMesage AS CDO.Message
>    LOCAL loCDOConfig AS CDO.Configuration
>
>    lcSchema    = [http://schemas.microsoft.com/cdo/configuration/]
>    loCDOConfig = CREATEOBJECT([CDO.Configuration])
>    WITH loCDOConfig.FIELDS
>         .ITEM(lcSchema + [smtpserverport])   = 25
>         .ITEM(lcSchema + [sendusing])        = 2
>         .ITEM(lcSchema + [smtpserver])       = "smtp.freesmtpservers.com"
>         .ITEM(lcSchema + [smtpauthenticate]) = 0
>         .ITEM(lcSchema + [sendusername])     = ""
>         .ITEM(lcSchema + [sendpassword])     = ""
>         .ITEM(lcSchema + [smtpusessl])       = .f.
>         .UPDATE()
>    ENDWITH
>    loCDOMesage = CREATEOBJECT([CDO.Message])
>    loCDOMesage.Configuration = m.loCDOConfig
>    loCDOMesage.BodyPart.Charset     = "utf-8"
>
>    WITH loCDOMesage
>         .From     = "from@somemail.com"
>         .To       = "to@somemail.com"
>         .Subject  = "This is a test"
>         .HTMLBody = "Test of the body contets"
>         .HTMLBodyPart.Charset = "utf-8"
>         .TextBodyPart.Charset = "utf-8"
>         TRY
>            .Send()
>         CATCH TO oError
>            MesageBox(oError.Message)
>         ENDTRY
>    ENDWITH
>
>    loCDOMesage = NULL
>    loCDOConfig = NULL
>    RELEASE loCDOConfig, loCDOMesage
>RETURN ""
>
>
>***** UPDATE
>Maybe Chilkat smtpauthenticate equivalent is TRUE by default?
>Maybe if you change it to FALSE it will work?
>
>
>>I'm just getting started replacing an old email module I wrote for a client that doesn't seem to be working for their customers anymore.
>>
>>For various reasons, choosing to do this with Chilkat and the new ChilkatVFP wrapper. I've figured out the code I need to create and send an email, but I'm struggling in testing it. When I tried to configure it to use the SMTP server associated with my Office365-based Exchange Server, I got authentication errors.
>>
>>I poked around and found a cool site that provides a test SMTP server online so you can test email issues (https://www.wpoven.com/tools/free-smtp-server-for-testing). Even found a different site that lets you test sending via SMTP (https://smtpserver.com/smtptest). When I use the second site to send an email using the first site's server, the email goes through without error, so I know I've got the right SMTP settings.
>>
>>But when I use my code to try to send via the first site, I time out. This is really simple code, just to make sure I can make it all work. After the necessary SET PATH and SET CLASSLIB, it's just:
>>
>>
>>loEmail = CREATEOBJECT('Email')
>>loEmail.Subject = 'This is a test'
>>loEmail.Body = [Here's some content.]
>>loEmail.From = 'tamar@istesting.com'
>>?loEmail.AddTo('tamar@didthiswork.com')
>>
>>loMailMan = CREATEOBJECT('MailMan')
>>loMailman.smtphost = 'smtp.freesmtpservers.com'
>>loMailman.smtpport = 25
>>?loMailman.Sendemail(loEmail)
>>_cliptext = loMailMan.lasterrortext
>>
>>
>>The error message I get is:
>>
>>
>>ChilkatLog:
>>  SendEmail:
>>    DllDate: Oct 27 2023
>>    ChilkatVersion: 9.5.0.96
>>    UnlockStatus: 0
>>    Architecture: Little Endian; 32-bit
>>    Language: ActiveX
>>    VerboseLogging: 0
>>    Auto unlock for 30-day trial
>>    UnlockStatusMsg: Unlocked for 30-day trial
>>    UnlockStatus: 1
>>    sendEmailInner:
>>      ReadTimeout: 30000
>>      renderToMime_pt1:
>>        createEmailForSending:
>>          Auto-generating Message-ID
>>        --createEmailForSending
>>      --renderToMime_pt1
>>      sendMimeInner:
>>        ensureSmtpSession:
>>          ensureSmtpConnection:
>>            smtpParams:
>>              SmtpHost: smtp.freesmtpservers.com
>>              SmtpPort: 25
>>              SmtpUsername: 
>>              SmtpSsl: 0
>>              StartTLS: 0
>>            --smtpParams
>>            smtpConnect:
>>              smtpHostname: smtp.freesmtpservers.com
>>              smtpPort: 25
>>              connectionIsReady:
>>                SMTP host changed.
>>                Need new SMTP connection...
>>              --connectionIsReady
>>              smtpSocketConnect:
>>                socket2Connect:
>>                  connect2:
>>                    connectSocket_v2:
>>                      connect_domain:
>>                        Connection attempt failed.
>>                        maxWaitTimeMs: 30000
>>                        totalMsWaitedSoFar: 17550
>>                        Failed.
>>                      --connect_domain
>>                    --connectSocket_v2
>>                    ConnectFailReason: Connection rejected
>>                    A few possible causes for a connection being rejected are:
>>                    - A firewall (software or hardware), such as Windows Firewall, is blocking the connection .
>>                    - Nothing is listening at the remote host:port
>>                  --connect2
>>                --socket2Connect
>>                Failed to connect to SMTP server..
>>              --smtpSocketConnect
>>            --smtpConnect
>>          --ensureSmtpConnection
>>        --ensureSmtpSession
>>      --sendMimeInner
>>    --sendEmailInner
>>    Failed.
>>  --SendEmail
>>--ChilkatLog
>>
>>
>>Any suggestions about what I'm missing here?
>>
>>Tamar
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform