Alpha Software Mobile Development Tools:   Alpha Anywhere    |   Alpha TransForm subscribe to our YouTube Channel  Follow Us on LinkedIn  Follow Us on Twitter  Follow Us on Facebook



The Alpha Software Forum Participation Guidelines

The Alpha Software Forum is a free forum created for Alpha Software Developer Community to ask for help, exchange ideas, and share solutions. Alpha Software strives to create an environment where all members of the community can feel safe to participate. In order to ensure the Alpha Software Forum is a place where all feel welcome, forum participants are expected to behave as follows:
  • Be professional in your conduct
  • Be kind to others
  • Be constructive when giving feedback
  • Be open to new ideas and suggestions
  • Stay on topic

Be sure all comments and threads you post are respectful. Posts that contain any of the following content will be considered a violation of your agreement as a member of the Alpha Software Forum Community and will be moderated:
  • Spam.
  • Vulgar language.
  • Quotes from private conversations without permission, including pricing and other sales related discussions.
  • Personal attacks, insults, or subtle put-downs.
  • Harassment, bullying, threatening, mocking, shaming, or deriding anyone.
  • Sexist, racist, homophobic, transphobic, ableist, or otherwise discriminatory jokes and language.
  • Sexually explicit or violent material, links, or language.
  • Pirated, hacked, or copyright-infringing material.
  • Encouraging of others to engage in the above behaviors.

If a thread or post is found to contain any of the content outlined above, a moderator may choose to take one of the following actions:
  • Remove the Post or Thread - the content is removed from the forum.
  • Place the User in Moderation - all posts and new threads must be approved by a moderator before they are posted.
  • Temporarily Ban the User - user is banned from forum for a period of time.
  • Permanently Ban the User - user is permanently banned from the forum.

Moderators may also rename posts and threads if they are too generic or do not property reflect the content.

Moderators may move threads if they have been posted in the incorrect forum.

Threads/Posts questioning specific moderator decisions or actions (such as "why was a user banned?") are not allowed and will be removed.

The owners of Alpha Software Corporation (Forum Owner) reserve the right to remove, edit, move, or close any thread for any reason; or ban any forum member without notice, reason, or explanation.

Community members are encouraged to click the "Report Post" icon in the lower left of a given post if they feel the post is in violation of the rules. This will alert the Moderators to take a look.

Alpha Software Corporation may amend the guidelines from time to time and may also vary the procedures it sets out where appropriate in a particular case. Your agreement to comply with the guidelines will be deemed agreement to any changes to it.

Bonus TIPS for Successful Posting

Try a Search First
It is highly recommended that a Search be done on your topic before posting, as many questions have been answered in prior posts. As with any search engine, the shorter the search term, the more "hits" will be returned, but the more specific the search term is, the greater the relevance of those "hits". Searching for "table" might well return every message on the board while "tablesum" would greatly restrict the number of messages returned.

When you do post
First, make sure you are posting your question in the correct forum. For example, if you post an issue regarding Desktop applications on the Mobile & Browser Applications board , not only will your question not be seen by the appropriate audience, it may also be removed or relocated.

The more detail you provide about your problem or question, the more likely someone is to understand your request and be able to help. A sample database with a minimum of records (and its support files, zipped together) will make it much easier to diagnose issues with your application. Screen shots of error messages are especially helpful.

When explaining how to reproduce your problem, please be as detailed as possible. Describe every step, click-by-click and keypress-by-keypress. Otherwise when others try to duplicate your problem, they may do something slightly different and end up with different results.

A note about attachments
You may only attach one file to each message. Attachment file size is limited to 2MB. If you need to include several files, you may do so by zipping them into a single archive.

If you forgot to attach your files to your post, please do NOT create a new thread. Instead, reply to your original message and attach the file there.

When attaching screen shots, it is best to attach an image file (.BMP, .JPG, .GIF, .PNG, etc.) or a zip file of several images, as opposed to a Word document containing the screen shots. Because Word documents are prone to viruses, many message board users will not open your Word file, therefore limiting their ability to help you.

Similarly, if you are uploading a zipped archive, you should simply create a .ZIP file and not a self-extracting .EXE as many users will not run your EXE file.
See more
See less

email_smtp_send error trapping

  • Filter
  • Time
  • Show
Clear All
new posts

  • email_smtp_send error trapping

    I am attempting to send email via amazon SES mail server. I am getting intermittent success and failures. It seems that sometimes the message I am sending never hits their server, although flag = email_smtp_send(pm,ps) returns true.

    If there a log somewhere or a method to trap any result or response that would indicate where this is going wrong?

    dim SMTP as c = ""
    dim TCPPort as n = 587
    dim Username as c = "username"
    dim EmailPassword as c = "password"
    dim EmailReturnAddress as c = "[email protected]"
    dim Mode as c = "TLS"

    dim pm as P
    dim ps as P
    dim msg as c = "Test Message"
    dim subject as c = "Test Subject"

    flag = (email_smtp_open(ps, SMTP, TCPport, UserName, EmailPassword, Mode))

    if flag = .t. then = "[email protected]"
    pm.from = "[email protected]"
    pm.subject = "Test from code editor 1530"
    pm.html_message = "This is a test"

    flag = email_smtp_send(pm,ps)

  • #2
    Re: email_smtp_send error trapping

    Check out:


    • #3
      Re: email_smtp_send error trapping

      Here is an update....

      email_smtp_send does not capture the complete conversation with an smtp server. So there is no help in diagnosing the problem.

      It appears that email_smtp_send has trouble, at least when sending to, with TLS mode.
      If I change to SSL, using port 465, it works reliably.

      I am wondering if anyone can comment on why email_smtp_send fails using TLS.

      Secondly, I have found when using the code in post#1, if I add any code, even debug(1), after the final line of code, it sends successfully.
      Any ideas on that?


      • #4
        Re: email_smtp_send error trapping

        Here is a udf that I have used to send email via for several years using alpha 5 v9 and v12. It has run quite well. Note I am not setting the mode but I guess SSL is the default. Occasionaly the first send attemp fails hence the second try after a pause. Maybe that is why a debug helps.
        I hope this helps,

        'Date Created: 25-Dec-2010 11:46:46 AM
        'Last Updated: 15-Oct-2015 09:09:14 PM
        'Created By  : Irwin
        'Updated By  : Administrator
        'Result is < 10 if the email was not sent
        'open1	send1a  send1b 	open2   send2a  send2b	total
        ' 0			x      x		0       x       x		0     neither open
        ' 1			0      0		0       x       x		1     1st open, no send, 2nd no open
        ' 0			x      x		2       0       0		2     2nd open, no send
        ' 1			0      0		2       0       0		3     both open, neither send
        ' 1			10     x 		x       x      	x		11    1st open and send1a
        ' 1			0     100		x       x      	x		101   1st open and send1b
        ' 0			x      x		2      20      	x		22    1st no open, 2nd open and send2a
        ' 0			x      x		2      0      	200		202   1st no open, 2nd open and send2b
        ' 1			0      0		2      20      	x		23    1st open, no send, 2nd open and send2a
        ' 1			0      0		2      0      	200		203   1st open, no send, 2nd open and send2b
        'sent > 10, failed < 10
        function emailcore as n (loginid as c, thesubject as c, thetext as c, theattachments as c)
        emailcore = 0
        dim pm as P
        dim ps as P
        dim eflag as l
        eflag = .f.
        ps.timeout = 10000
        eflag = email_smtp_open(ps, "email_server", 3535, "email_user", "password")
        if eflag
        	emailcore = emailcore + 1 = alltrim(demoval("Prefemail", loginid))	'get email address to send to
        	pm.from = "my_email_addr"
        	pm.from_alias = "alias"
        	pm.subject = thesubject
        	pm.attachments = theattachments
        	pm.message = thetext
        	eflag = email_smtp_send(pm, ps)		'send 1a
        	if eflag	'.f.=not sent, .t.=sent
        		emailcore =  emailcore + 10
        		eflag = email_smtp_send(pm, ps)	'send 1b
        		if eflag
        			emailcore = emailcore + 100
        		end if
        	end if
        	if .not. email_smtp_close(ps)
        		emailcore = emailcore - 1000
        	end if
        end if
        if eflag = .f.	'.f.=not sent, .t.=sent
        	ps.timeout = 10000
        	eflag = eemail_smtp_open(ps, "email_server", 3535, "email_user", "password")
        	if eflag
        		emailcore = emailcore + 2
 = alltrim(demoval("Prefemail", loginid))	'get email address to send to
        		pm.from = "my_email_addr"
        		pm.from_alias = "alias"
        		pm.subject = thesubject
        		pm.attachments = theattachments
        		pm.message = thetext
        		eflag = email_smtp_send(pm, ps)		'send 2a
        		if eflag	'.f.=not sent, .t.=sent
        			emailcore = emailcore + 20
        			eflag = email_smtp_send(pm, ps)	'send 2b
        			if eflag
        				emailcore =  emailcore + 200
        			end if
        		end if
        		if .not. email_smtp_close(ps)
        			emailcore = emailcore - 2000
        		end if
        	end if
        end if
        end function


        • #5
          Re: email_smtp_send error trapping

          That is a nice method to make repeated attempts to open the connection and send until it sends successfully, but I don't think it addresses my issues.

          email_smtp_open default mode is "", so it is not using SSL or TLS.

          I am only seeing my attempts failing when using TLS. With SSL it works every time.

          The documentation for email_smtp_open says it can use TLS.

          I would like see a comment from Alpha, or anyone who has experienced problems or success with TLS.


          • #6
            Re: email_smtp_send error trapping

            It may be a timing issue, and Irwin's code gives you a hint about what might help. In trying to figure out a problem with Office365 SMTP mail it was found a larger timeout was needed. Maybe that would help here... at least worth a try. Try setting ps.timeout = 25000 or larger... and then, if it works, back down until it starts failing again.


            • #7
              Re: email_smtp_send error trapping

              I will try experimenting with the timeout, but the timeout is "The number of milliseconds the function will wait to establish the connection before timing out." And the problem I am having is not the connection to the server, it is the email_smtp_send that fails.

              I am also going to set up with another email service that uses TLS to see if I get the same problem.

              Irwin, I just notice that one line in your code reads "eemail_smtp_open", with an extra "e". That part must not ever fire, as it should throw an error.


              • #8
                Re: email_smtp_send error trapping

                Understood... but... using the built-in Email Settings for testing (View, Settings, Email) the Test in this section reports back the various stages of connection. I could see my connection as successful, but the email send failed. Changed the timing and it seems ok. Just something to try. My own ISP has no issues with the default timing. But Office365 was failing.


                • #9
                  Re: email_smtp_send error trapping


                  I did not know that was there! It may be just what I have been looking for!

                  I will be testing this weekend.

                  Thank you, David .


                  • #10
                    Re: email_smtp_send error trapping

                    Thanks Joe about: Irwin, I just notice that one line in your code reads "eemail_smtp_open", with an extra "e". That part must not ever fire, as it should throw an error.
                    That was a typo entered when I revised the line to remove my account and password. I look forward to you testing results.


                    • #11
                      Re: email_smtp_send error trapping

                      I thought that the built-in email settings are only for the email_send and email_send2 command, or for sending emails using the built in alpha five functionality, such as that found on desk top applications in the tools|e-mail wizard.
                      Richard Urban

                      Grocery Delivery Software for Stores and Entrepreneurs: