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

Announcement

Collapse

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

using email_send_mandrill()

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    using email_send_mandrill()

    Woul like to report on this new function. After a suggestion from Selwyn, I tried it.

    In my scenario, I have printed invoices with a barcode. Once printed, they must go to proofing before they can be sent.

    After they are proofed, there will often be a big stack - maybe 50 to 100 that they want to send.

    So the operater scans them with a barcode reader (to a temporary file) and then I send them all at once.

    We were running into issues with the provider, basically smtp issues, using either Outlook or Alpha's email.

    I signed up for Mandrill, got a key, etc. Then I tested sending 100 emails. Worked flawlessly. For 100, takes maybe 60 seconds.

    So I can highly recommend it - to get instructions look in the release notes, and search for Mandrill.

    PS: the first 12,000 emails each month are free! After that it is a pittance for the cost.
    Cole Custom Programming - Terrell, Texas
    972 524 8714
    [email protected]

    ____________________
    "A young man who is not liberal has no heart, but an old man who is not conservative has no mind." GB Shaw

    #2
    Re: using email_send_mandrill()

    Martin,

    It has been 4 months since you started using Mandrill for your email. Are you still satisfied with them? We are struggling to find a reasonable email service that allows our officers (we are non-profit educational association) to send out monthly newsletters, etc.

    We are divided into districts that may have as many as 500 members each. The issue we are experiencing is that sending out such an email triggers SPAM designations, etc. We use iContact for bulk emails to all 5,000 members with no problems. We tried having Zebrahost develop a live connection to our database using their Email Marketer product but they were unable to make it work.

    We are looking for a solution that allows smaller email sets to be sent out (50 to 500) based upon a grid search of WITHOUT triggering SPAM classifications. Would Mandrill do the trick (based upon your experience)

    Greg

    Comment


      #3
      Re: using email_send_mandrill()

      Yes, completely satisfied. I also have a private version of the code, that will most likely run on almost any verson of Alpha, like 10.5 for example. However, that vesrion was privately produced, and not available, free.

      Most Alpha clients would never exceed 12,000 per month, but even if you do, it costs a pittance per thousand. Most companies using Mandrill are sending massive amounts of emails.

      Because you are bypassing your email provider, the number you send at one time or per month is irrelavent. Will not trigger spam issues - which is why I went to it.
      Cole Custom Programming - Terrell, Texas
      972 524 8714
      [email protected]

      ____________________
      "A young man who is not liberal has no heart, but an old man who is not conservative has no mind." GB Shaw

      Comment


        #4
        Re: using email_send_mandrill()

        Martin,

        Thank you for the speedy reply! I appreciate you taking the time during the holiday season to give the feedback.

        Mandrill sounds like the way to go for our needs. We are running V12 on the WAS.

        You mention you have privately produced code that is not available for free. Is it available for purchase from the developer? (either you or the person/company who provided it for you) If so, I would be interested in discussing it further. Feel free to contact me via private message to discuss the details.

        Thank you again and Happy New Year!

        Comment


          #5
          Re: using email_send_mandrill()

          Hi there,
          I have looked in the wiki and also in the alpha anywhere help but was not able to find the documentation to use the
          email_send_mandrill() function. Would you be able to tell me where i can find this function and how to use it?
          Thank you so much your help is greatly appreciated.
          Calyxte

          Comment


            #6
            Re: using email_send_mandrill()

            I just found it...
            Thanks..

            http://downloads.alphasoftware.com/A...easenotes.html

            Email - Sending Email Using the Mandrill Email Service - Alpha Anywhere has always offered Xbasic functions to send email. However, these functions require that you have access to a SMTP mail server. The existing functions in Xbasic include:

            email_send()
            email_send2()
            email_send_noprofile()
            email_send_noprofile()
            With the emergence of email services, such as Mandrill (www.mandrillapp.com) an alternative, possibly easier, certainly more powerful, way of sending emails from your applications is now possible.
            A new function,
            email_send_mandrill()

            allows you to send email using the Mandrill service.
            Benefits of using a 3rd party emailing service include the easier setup, better deliverability, and access to powerful value added features offered by the service, such as tracking whether people open your email message, etc.
            The full functionality of the Mandrill email service can be read by navigating to this address:
            https://mandrillapp.com/api/docs/index.JSON.html
            In order to use the Mandrill email server, you will have to visit their web site and apply for a key. The key allows you to send a certain number of free emails each month. Beyond that, there is a fee.
            NOTE: Alpha Software is not involved in any way at all in the fee and does not receive any payment at all if you use the Mandrill service.
            There are two different ways in which you can use the email_send_mandrill() function.
            1. Simple Method: Define Message Using Xbasic Dot Variable
            In the simple method, you define an Xbasic dot variable that defines the properties of the message you want to send and then you call email_send_mandrill(), passing in your Mandrill key and the dot variable. This simple method does not expose all of the functionality of the Mandrill service, but it is very easy to set up and use, and it is great for simple email messages.
            For example:


            'create a .dot variable to define the message
            dim ms as p
            ms.send_to = "[email protected]:John Smith,[email protected]:Sally Jones"
            ms.send_to_cc = ""
            ms.send_to_bcc = ""
            ms.from_email = "[email protected]"
            ms.subject = "Information You Requested"
            ms.message_html = "Here is the <b>information</b> you requested."
            ms.message_text = "Plain text version of the message"
            ms.attachments = "c:\files\mychart1.pdf,c:\files\mytext1.txt"



            Notes About the Properties in the Dot Variable
            The .send_to and .send_to_cc addresses are a comma delimited list of addresses. The email address is followed (optionally) by a colon and then a friendly name.
            The .send_to_bcc property allows you to specify a single bcc address. If you specify more than one address, you will get an error.
            .send_to_cc and .send_to_bcc are optional. You can omit them entirely.
            .attachments is optional. It contains a comma delimited list of filenames to attach to the email.
            CC and BCC Addresses
            Even though the Dot variable allows you to specify separate comma delimited lists for the TO and CC addresses, in reality, Mandrill does not support CC addresses. Furthermore, Mandrill only supports a single BCC address.
            If you specify any CC addressesl, the TO list and the CC list of addresses is combined into a single list and the emails are sent to all addresses in the combined list. However, the Mandrill internal .preserve_recipients property is set to false, so that none of the recipients will see the names of any other recipients.
            If you provided a list of names in the TO list, and no names in the CC list, the recipients of the email would all be able to see the names of the other recipients.
            Once you have defined the .dot variable, you can send the message. For example

            dim pResult as p
            pResult = email_send_mandrill("mysecretkey",ms)

            The function returns a .dot variable with several properties:
            .error - a logical value .t. or .f.
            .result - an Xbasic array with one item for each address in the recipient list
            .json - the JSON settings that were constructed from the .dot variable passed into the function. You can use this value as a starting point should you wish to use the second method (described below) for calling the email_send_mandrill() function
            Here is what a typical item in the .result array looks like:
            result[1].email = "[email protected]"
            result[1].status = "sent"
            result[1]._id = "some message id" --- used to make queries against the Mandrill API for message status

            Here is a complete example of sending an email in the simplest possible way (eliminating all optional properties in the Xbasic .dot variable). As you can see, it just a few lines of code.
            'create a .dot variable to define the message
            dim ms as p
            ms.send_to = "[email protected]:John Smith,[email protected]:Sally Jones"
            ms.from_email = "[email protected]"
            ms.subject = "Information You Requested"
            ms.message_html = "Here is the <b>information</b> you requested."
            dim pResult as p
            pResult = email_send_mandrill("mysecretkey",ms)


            Alternative Method for Specifying Attachments - Specifying the Attachment Data
            We have previously indicated that attachments are specified by setting the .attachments property to a comma delimited list of filenames. An alternative method is to set the .attachmentsArray property as a property array with .name, .type and .content properties.
            Where:
            .name - the filename (no drive/path, just the name and extension) of the file.
            .type - the mime type
            .content - the base64 encoded data

            For Example
            dim ms.attachmentsArray[1] as p
            ms.attachmentsArray[1].name = "chart.pdf"
            ms.attachmentsArray[1].type = resolve_mime_type("pdf")
            ms.attachmentsArray[1].content = base64encode(file.to_blob("c:\myfiles\chart.pdf"))


            Merge Variables - Mail Merge Variables into the Message Body and Subject
            An advanced feature of the Mandrill service is to allow you to specify placeholders in the message subject and body that will be replaced with variables that you supply at the time Mandrill sends out the email to each recipient.
            The format for the placeholders is:
            *|VariableName|*

            For example, here is how the message subject or body could have been specified using placeholders:
            ms.subject = "*|Fname|*, here is the Information You Requested"
            ms.message_html = "*|Fname|* *|Lname|* here is the information you requested."

            When you use placeholders in the subject or body, you must specify the placeholder values. Obviously, you need to specify placeholder values for each recipient.
            For example, assume that you had specified two recipients as follows:
            ms.send_to = "[email protected]:John Smith,[email protected]:Sally Jones"

            You would then need to specify the FName and LName variables for [email protected] and for [email protected].
            Here is how you would do this:

            'define the .merge_vars[] array with 2 items
            dim ms.merge_vars[2] as p

            'define the actual variables for the first recipient.
            'since there are two variables, we define a sub-array with two items
            dim ms.merge_vars[1].vars[2] as p

            'here are the variables for the first recipient
            ms.merge_vars[1].vars[1].name = "FName"
            ms.merge_vars[1].vars[1].content = "John"
            ms.merge_vars[1].vars[2].name = "LName"
            ms.merge_vars[1].vars[2].content = "Smith"
            ms.merge_vars[1].rcpt = "[email protected]

            'here are the variables for the second recipient
            dim ms.merge_vars[2].vars[2] as p
            ms.merge_vars[2].vars[1].name = "FName"
            ms.merge_vars[2].vars[1].content = "Sally"
            ms.merge_vars[2].vars[2].name = "LName"
            ms.merge_vars[2].vars[2].content = "Jones"
            ms.merge_vars[2].rcpt = "[email protected]

            In addition to supplying merge variables for each recipient, you can also supply global merge variables - for all recipients. You do this by specifying the .global_merge_vars property array. If a merge variable is defined at the individual recipient level, it will override the corresponding global merge variable.
            For example:
            dim ms.global_merge_vars[1] as p
            ms.global_merge_vars[1].name = "Company"
            ms.global_merge_vars[1].content = "Alpha Software"


            Using a DataSource Property
            Instead of supplying the actual email addresses and merge variables directly in the dot variable you can pass in a 'dataSource' (an array of JSON objects), and then indicate that the .send_to property should be populated from the data source.

            For example, consider the following definition of the .dataSource property:
            ms.dataSource = <<%txt%
            [
            {email: "[email protected]", firstName: "Sam", lastname: "Smith"},
            {email: "[email protected]", firstName: "Joe", lastname: "Jones"}

            ]
            %txt%
            If the above .dataSource property has been defined, then you can define the .sent_to property as follows:

            ms.send_to = "{datasource:email}"

            This indicates that the .send_to property should be populated from the 'email' property in the dataSource.
            If you pass in a .dataSource property, then there is no need to pass in the .merge_vars property - these properties are automatically generated from the data in the .dataSource property.
            Here is what happens if you pass in a .dataSource property: The .message_html, .message_text and .subject properties are scanned to see if any merge-variables are used. If any merge variables are found in any of these properties, then the merge variables for each address are automatically extracted from the .dataSource property.
            Using the .dataSource property, it is extremely easy to create a mass mailing with custom merge variables for each recipient.

            2. Advanced Method: Define Message Using a JSON String
            The JSON method exposes the full functionality of the Mandrill service. To see all of the options that are available, please see the Mandrill API documentation.
            If you want to use advanced features, like track opens, or schedule delivery, you will need to use this option.
            Here is an example of how you can use this method:


            DIM json as C = <<%str%
            {
            "message": {
            "to": [
            {
            "email": "[email protected]",
            "name": "John Smith"
            }
            ],
            "from_email": "[email protected]",
            "subject": "Information You Requested",
            "html": "Here is the <b>information</b> you requested",
            "text": "Plain Text Message",
            "preserve_recipients": false
            },
            "asynch": false,
            "ip_pool": null,
            "send_at": null
            }
            %str%
            dim pResult as p
            pResult = email_send_mandrill("mysecretkey",json)

            Generating the JSON String From Xbasic
            Xbasic has powerful functions for generating JSON from an Xbasic dot variable. For example, the json_generate() function will generate JSON from a .dot variable. A powerful way to programmatically construct the JSON string that you pass into the email_send_mandrill() function is to build up an Xbasic .dot variable with the various properties that you want to set, then call json_generate() to generate the JSON.

            Comment


              #7
              Re: using email_send_mandrill()

              Did you get all of that???

              :)

              Comment


                #8
                Re: using email_send_mandrill()

                This is great thanks for posting this. Have you figured out how to get an error to the user if the email fails?
                I have been playing with it a bit but nothing yet.
                Chad Brown

                Comment


                  #9
                  Re: using email_send_mandrill()

                  Here is a function I use for Mandrill
                  Code:
                  function mandrill_send as L(subject,message,attachment)
                  	if HOSTAVAILABLE("smtp.mandrillapp.com",587)=.t.
                  	else
                  		sleep(5)
                  		timedout=timedout + 1
                  		goto wasbusy
                  '		mandrill_send=.f.
                  '		exit function 
                  		end 
                  	end if 
                  	dim shared myaddress as c
                  	dim shared emailto as c	
                  	dim shared attachment as c
                  	dim shared subject as c
                  	dim shared message as c	
                  	dim usename as c = "redacted"
                  	dim pass as c = "redacted"
                  	dim mailfrom as c = "smtp.mandrillapp.com"
                  	dim ps as p
                  	dim pm as p
                  	dim pm.subject as c
                  	dim pm.message as c
                  	dim pm.html_message as c
                  	subject="Prime Aerospace Testing Requirements"
                  	if (email_smtp_open(ps, mailfrom, 587, usename, pass)) then
                  	    pm.to = var->emailto
                  	    pm.from = var->myaddress
                  	    pm.subject = var->subject
                  	    pm.message = var->message
                  	    pm.attachments = var->attachment
                  	    email_smtp_send(pm, ps)
                  	else
                  	  	mandrill_send=.f.
                  	  	pDlg1.close()
                  	  	email_smtp_close(ps)
                  	  	exit function 
                  	end if
                  	email_smtp_close(ps)
                  	mandrill_send=.t.
                  end function
                  It the sender does not have a good and reliable broadband provider with a decent amount of broadband speed, then you may periodically lose contact with the internet temporarily and get a fail - if that happens, (if it returns false) tell the operator what happened and to run it again. If the hostavailable fails tell them they don't have internet connectivity.
                  Last edited by martinwcole; 03-30-2015, 11:40 AM.
                  Cole Custom Programming - Terrell, Texas
                  972 524 8714
                  [email protected]

                  ____________________
                  "A young man who is not liberal has no heart, but an old man who is not conservative has no mind." GB Shaw

                  Comment


                    #10
                    Re: using email_send_mandrill()

                    Hi Chad,
                    I have not personally figured out a way to get an error to the user.
                    While I have written and tested this code in another post,
                    http://www.alphasoftware.com/alphafo...ighlight=elbee
                    I have not yet used it on a production basis yet.
                    I have been using Mandrill now for about 6 months through an eMail relay server and that has always worked great.
                    The amount of emails I send through the relay server is only maybe 100 at a pop so pretty simple.
                    I will be using my other code in a production basis later on sometime in May and your welcome to check in with me again to see how it is working for me.
                    When I move to the production server I will be ramping up my sending of emails from 100's now to 10,000's and growing to 100,000's per day.
                    This is where the other code that I wrote will be a huge help in getting those emails out in a minute or two versus days!!

                    Comment

                    Working...
                    X