Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

SendMail

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

    SendMail

    Hi,

    I can successfully send test mails from Options->Misc but when I try and use SendMail() from an indicator it doesnt seem to work. I dont receive any errors, just no email. Any ideas?

    (I'm using the exact same To, From, Subject and Content as the test mail sends)

    Regards

    #2
    Check this out (handbook of NT 6.5):

    SendMail - it will only work in real-time.

    Code:
    SendMail(string from, string to, string subject, string text)

    Example:
    // Generates an email message
    SendMail("[email protected]", "[email protected]", "Trade Alert",
    "Buy ES");

    Tips:
    1. If mails are not sent, check the Control Center Log tab for any error information. You can
    also try changing the SMTP outgoing mail server to use your own ISP's mail server. You can
    set this information via the Control Center window Tools > Options > Misc.

    You use own SMTP or the SMTP from NT?

    Comment


      #3
      I use gmail with all the settings entered correctly - as mentioned it works when I use Test from Options->Misc

      I have it coded correctly:

      SendMail("[email protected]", "[email protected]", "NinjaTrader test mail", "This is a test mail");

      And have added Prints() before and after to check it is executing.

      Absolutely no idea why its not working. The testmail appears in the log but the SendMail() doesnt (which I take to be normal behaviour).

      Comment


        #4
        Tools/Options/Misc:

        Instead leave blank try this:

        Server: smtp.googlemail.com
        Port:465 (!!!)
        SSL=true
        User: [email protected]

        Activate in googlemail.com/preferences pop3!

        Good luck!

        Comment


          #5
          Only port 587 seems to work for the test mail (as per the suggested setting on gmail).

          Thanks for the help though

          Comment


            #6
            spinalwiz,

            Maybe try your ISP's SMTP?
            Josh P.NinjaTrader Customer Service

            Comment


              #7
              1. (options/ATI/General) Disable SMTP server
              2. (options/misc) server - smtp.gmail.com port 587 and turn on ssl. Userid/pwd - gmail's acct
              3. Enable POP in gmail settings

              Comment


                #8
                Hi,

                Yes, test mail works fine with my ISPs SMTP settings. So in summary the following work fine with test mail:

                1)Gmail settings
                2)My ISPs settings
                3)The default Ninjatrader settings

                but none work when SendMail is called from an indicator. Hard to understand why as surely it is the same routine being used.

                Nevermind, will just program something manually.

                Comment


                  #9
                  same thing...

                  Hi,

                  I am having this same exact issue. I am running NT 7.0.0.15. Is there a work around for this?


                  thanks

                  Comment


                    #10
                    Hi trade.ripper,

                    Is the test mail going through in your case as well?
                    KyleNinjaTrader Customer Service

                    Comment


                      #11
                      Hi,

                      Yes the test email works fine.

                      I have run through several different iterations (changing all of the different variables) and nothing seems to be working.

                      The log is showing an SmtpExcetion and says the operation has timed out.

                      Comment


                        #12
                        trade.ripper, what is the exact text of the SmtpException? That means there is something going wrong with the actual sending portion of the email, not necessarily something wrong with NinjaTrader.

                        If you can't get it to work, there are plenty of C# email libraries floating around the internet and you just integrate one of those into your indicator to send emails.
                        AustinNinjaTrader Customer Service

                        Comment


                          #13
                          I got it working now! Im not sure what the exact problem was. Perhaps just restarting fixed it. My problem now - its working too well - I'm getting 57emails for each alert. Any ideas on why that might be?


                          thanks!

                          Comment


                            #14
                            Hello trade.ripper,

                            I'm glad to hear that you have the mail function working.

                            As far as why 57 messages were generated for this alert, it would depend on your code. If, for example, your code reaches the SendMail line 57 times, then 57 emails would be generated.

                            I would suggest adding a Print() before the SendMail() line to see how many times the code is reaching this line.
                            KyleNinjaTrader Customer Service

                            Comment

                            Latest Posts

                            Collapse

                            Topics Statistics Last Post
                            Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                            0 responses
                            607 views
                            0 likes
                            Last Post Geovanny Suaza  
                            Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                            0 responses
                            353 views
                            1 like
                            Last Post Geovanny Suaza  
                            Started by Mindset, 02-09-2026, 11:44 AM
                            0 responses
                            105 views
                            0 likes
                            Last Post Mindset
                            by Mindset
                             
                            Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                            0 responses
                            560 views
                            1 like
                            Last Post Geovanny Suaza  
                            Started by RFrosty, 01-28-2026, 06:49 PM
                            0 responses
                            561 views
                            1 like
                            Last Post RFrosty
                            by RFrosty
                             
                            Working...
                            X