ScriptUO

Scripting Resources & Utilities => Stealth Client => Topic started by: smitty on December 10, 2017, 08:03:12 PM

Title: [C#] send texts
Post by: smitty on December 10, 2017, 08:03:12 PM
Hello everyone!
I did some research and found some code to send text messages, after some reworking, I wrote this class.
figured i would share what i have learned.

Code: [Select]
using System;
using System.Net;
using System.Net.Mail;

namespace Hunter
{
    public class Communicator
    {
        private string _sender;
        private string _password;
        private long _telephoneNumber;
        private string _gateWay;
        private string _recipient;

        //list of gateways
        //https://en.wikipedia.org/wiki/SMS_gateway

        public Communicator(string sender, string password, long telephoneNumber, string gateWay)
        {
            _sender = sender;
            _password = password;
            _telephoneNumber = telephoneNumber;
            _gateWay = gateWay;
            _recipient = string.Concat(new object[] { _telephoneNumber, '@', _gateWay });
        }

        public void sendTxtMsg(string subject, string message)
        {
            using (MailMessage textMessage = new MailMessage(_sender, _recipient, subject, message))
            {
                using (SmtpClient textmessageClient = new SmtpClient("smtp.gmail.com", 587))
                {
                    textmessageClient.UseDefaultCredentials = false;
                    textmessageClient.EnableSsl = true;
                    textmessageClient.Credentials = new NetworkCredential(_sender, _password);
                    Console.WriteLine("attempting to send sms...");
                    textmessageClient.Send(textMessage);
                }
            }
        }
    }
}

I made a separate gmail account and configured the account to "Let less secure apps use your account"
So when you make the communicator object, do something like this
Code: [Select]
Communicator textSender = new Communicator("SeperateEmail@gmail.com", "passWrdToSeperateEmail", 1238675309, "gatewayToCellCarrier.com");
textSender.sendTxtMsg("[TEST]","Testing...");
The first parameter is the new email that was created that is SENDING the msg
The second parameter is the password to the newly created email
The third parameter is the phone number that you want to receive the texts
The fourth parameter is the gateway. a list of gateways can be found in the class above.
Title: Re: [C#] send texts
Post by: JlM on September 09, 2018, 02:09:10 PM
Is it possible call this script from inside a python script I use? If not, does anyone have one that will work for python?
Title: Re: [C#] send texts
Post by: ZeroDX on September 09, 2018, 05:46:17 PM
Is it possible call this script from inside a python script I use? If not, does anyone have one that will work for python?
It is possible to send and recieve email-messages via python. those libraries will help: smtplib, poplib, imaplib