Announcement

Collapse

Forum Guidelines

This forum is for finished source code that is working properly. If you have questions about this or any other source code, please post it in one of the Discussion Forums, not here.
See more
See less

Send email class

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

    #21
    A small correction:
    iMsg.AddAttachment("<path of the file>")

    Again, thanks José

    Comment


      #22
      PB10 not found "ole2utils.inc" ???

      Comment


        #23
        ole2utils.inc is part of Jose's API header files. Make sure you point the PB compiler to the right INCLUDEs for this.

        Comment


          #24
          I've moved my original post to a more appropriate board here: http://www.powerbasic.com/support/pb...ad.php?t=52878
          Last edited by Martin Foster; 4 May 2013, 02:32 AM.

          Comment


            #25
            ANY missing parsing attachments

            clsEmail.inc
            Code:
            ' Create the attachment body section
                     IF LEN(m_Attachments) > 0 THEN
                        REM NumAttachments = PARSECOUNT( m_Attachments, ";," )
                        [B]NumAttachments = PARSECOUNT( m_Attachments, ANY ";," ) '8/17/13[/B]
                        REDIM sArray(1 TO NumAttachments) AS STRING
                        REM PARSE m_Attachments, sArray(), ";,"
                        [B]PARSE m_Attachments, sArray(), ANY ";," '8/17/13[/B]

            Comment


              #26
              Thanks Mike, true the "ANY" was missing.
              Last edited by Theo Gottwald; 18 Aug 2013, 02:21 AM.

              Comment


                #27
                On Windows Phones, I can not open PDF files when I send over this email-class. IPad fits with everything. But the Windows Phone can open the PDF files when I send the same files differently.

                Is there somewhere a little bug in the code?

                Comment


                  #28
                  Paul:

                  Have you considered adding a dns query for the mail exchange MX records and sending mail directly there?
                  ------------------------------------------------------------
                  sigpic

                  It has come to my attention that certain dubious forces are interpolating their desires in my search for Mom, apple pie and the girl you left behind. Stop it or I'll scream...

                  Comment


                    #29
                    Originally posted by Rick Kelly View Post
                    Have you considered adding a dns query for the mail exchange MX records and sending mail directly there?
                    Generally speaking, that's not such a good idea because you'll find a large percentage of your email getting bounced. Today, properly configured SMTP servers will not accept email from unauthenticated, "out of policy" senders and many of them use RBLs like Spamhaus ZEN that check if you're attempting to relay mail from a dynamically allocated IP and will block it.

                    The safest bet is to always submit your mail through your service provider's SMTP server (be it your residential ISP or corporate mail server) and let them handle the delivery.
                    Mike Stefanik
                    sockettools.com

                    Comment


                      #30
                      Originally posted by Mike Stefanik View Post
                      Generally speaking, that's not such a good idea because you'll find a large percentage of your email getting bounced. Today, properly configured SMTP servers will not accept email from unauthenticated, "out of policy" senders [...]
                      As a sys/mail admin, I can confim the above. Basically:
                      Code:
                      If sending IP address <> MX record of sender's domain Then
                         Handle as spam/Drop connection
                      Else
                         Accept email
                      End If

                      Comment


                        #31
                        If sending IP address <> MX record of sender's domain Then
                        Handle as spam/Drop connection
                        Else
                        Accept email
                        End If
                        BAD!!! You will drop all mail from quite a few of my clients and a heck of a lot of other organisations as well. Their MX records point to a cloud based spam/virus filter server which forwards to their in house mail server. This in house mail server sends all of their mail from a totally different IP address.

                        The correct test is:
                        Code:
                        If domain part of PTR record of sending IP address <> sender's domain Then
                           Handle as spam/Drop connection
                        Else
                           Accept email
                        End If
                        That is what PTR records are for.
                        =========================
                        https://camcopng.com
                        =========================

                        Comment


                          #32
                          Originally posted by Stuart McLachlan View Post
                          BAD!!! You will drop all mail from quite a few of my clients and a heck of a lot of other organisations as well. Their MX records point to a cloud based spam/virus filter server which forwards to their in house mail server. This in house mail server sends all of their mail from a totally different IP address.
                          No. If those "inhouse" servers send mail, they need too have a MX entry, too. Problem solved.

                          Comment


                            #33
                            Originally posted by Knuth Konrad View Post
                            No. If those "inhouse" servers send mail, they need too have a MX entry, too. Problem solved.
                            It might be a bit friendlier of you to also check for SPF records. I could see where there might be reasons that they don't want to advertise those systems as mail exchanges, even if they do handle mail internally.

                            But this is starting to get far afield of the source code issue, so we might want to discuss the vagaries of mail delivery elsewhere.
                            Mike Stefanik
                            sockettools.com

                            Comment


                              #34
                              > No. If those "inhouse" servers send mail, they need too have a MX entry, too. Problem solved.

                              Sorry, but that is 100% wrong.

                              An MX record tells external servers where to send mail TO for that domain.

                              When using an intermediate spam/filter server, best practice is to configure the organisation's router to only accept Port 25 connections from that filter server. If you create an MX record pointing to the sending server, outside organisations will end up trying to send direct to that address and will be blocked.

                              Even if you don't block Port 25 from other sources, creating an MX record pointing to the sending server WILL result in spam being sent direct to the in house server rather than to the filters.

                              Problem NOT solved. Problem compounded!
                              =========================
                              https://camcopng.com
                              =========================

                              Comment


                                #35
                                > It might be a bit friendlier of you to also check for SPF records

                                SPF is a brain-dead, misguided experimental protocol which is much abused and causes problems for many RFC compliant systems.
                                =========================
                                https://camcopng.com
                                =========================

                                Comment


                                  #36
                                  ... SPF is ... experimental protocol...
                                  Actually, I have clients that require SPF configuration to work with Google Apps.
                                  3.14159265358979323846264338327950
                                  "Ok, yes... I like pie... um, I meant, pi."

                                  Comment


                                    #37
                                    > Actually, I have clients that require SPF configuration to work with Google Apps.

                                    So do I and I always set them up with +all at the end , but that doesn't alter my opinion about it
                                    =========================
                                    https://camcopng.com
                                    =========================

                                    Comment


                                      #38
                                      Hi,

                                      nice code and good to learn the CLASS programming

                                      I found an error when SendFrom is filled with a eMail adress like this:

                                      cMail.SendFrom = "Harry Testmann <[email protected]>"

                                      To fix that change:

                                      Code:
                                      ' Tell the mailhost who we are
                                      TCP PRINT hTCP, "MAIL FROM:<" & m_From & ">"
                                      to
                                      Code:
                                      y = INSTR(m_from, "<")
                                      IF y THEN
                                          TCP PRINT hTCP, "MAIL FROM:" & MID$(m_from,y)
                                      ELSE
                                          TCP PRINT hTCP, "MAIL FROM:<" & m_From & ">"
                                      END IF
                                      Last edited by Hubert Brandel; 26 Mar 2014, 09:27 AM. Reason: syntax error
                                      Regards,
                                      Hubert

                                      ------------------------------------
                                      http://familie-brandel.de/index_e.html

                                      Comment


                                        #39
                                        You might also try using this function to validate & extract the e-mail address

                                        Code:
                                        FUNCTION ISEMAIL(BYVAL e AS STRING, MailAddr as string) AS LONG
                                        '------------------------------------------------------------
                                        ' verifies that the passed string contains at least one
                                        ' valid e-mail address and returns a fixed up version
                                        '------------------------------------------------------------
                                          LOCAL Mask    AS STRING
                                          LOCAL p       AS LONG
                                          LOCAL l       AS LONG
                                        
                                          MailAddr = ""
                                          IF LEN(e) = 0 THEN
                                            FUNCTION = 0
                                            EXIT FUNCTION
                                          END IF
                                        
                                          Mask = "([a-z0-9._-]+)(@[a-z0-9._-]+)(\.[a-z]+)"
                                          REGEXPR Mask IN e TO p,l
                                        
                                          if l > 0 then MailAddr = "<" + mid$(e,p,l) + ">"
                                        
                                          FUNCTION = (l > 0)
                                        
                                        END FUNCTION
                                        Real programmers use a magnetized needle and a steady hand

                                        Comment


                                          #40
                                          I found an issue that sometimes the date would be set to 1/1/1970.

                                          I later pinpointed the issue to the user's locale where Mon 12 May 2014 would be, for example,in Italy, Lun 12 Mag 2014 and the SMTP server will not recognize it.

                                          To fix this issue I changed the folloing code:

                                          Code:
                                                 szFormat = "ddd',' dd MMM yyyy"
                                                 GetDateFormat %[B]LANG_INVARIANT[/B], 0, t, szFormat, szTemp, SIZEOF(szTemp)
                                                 sResult = szTemp
                                          
                                                 szFormat = "HH':'mm':'ss"
                                                 GetTimeFormat %[B]LANG_INVARIANT[/B], 0, t, szFormat, szTemp, SIZEOF(szTemp)
                                          Last edited by Gary Beene; 7 Aug 2014, 12:28 AM. Reason: Code: tags
                                          Andrea Mariani
                                          AS/400 expert
                                          Basic programmer @ Home

                                          Comment

                                          Working...
                                          X
                                          😀
                                          🥰
                                          🤢
                                          😎
                                          😡
                                          👍
                                          👎