Author Topic: [C#] send texts  (Read 4032 times)

0 Members and 1 Guest are viewing this topic.

Offline smittyTopic starter

  • Jr. Member
  • **
  • Posts: 28
  • Activity:
    0%
  • Reputation Power: 1
  • smitty has no influence.
  • Respect: +1
  • Referrals: 0
    • View Profile
[C#] send texts
« on: December 10, 2017, 08:03:12 PM »
+1
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.
« Last Edit: December 10, 2017, 08:14:57 PM by smitty »

Offline JlM

  • Jr. Member
  • **
  • Posts: 10
  • Activity:
    0%
  • Reputation Power: 1
  • JlM has no influence.
  • Respect: 0
  • Referrals: 0
    • View Profile
Re: [C#] send texts
« Reply #1 on: September 09, 2018, 02:09:10 PM »
0
Is it possible call this script from inside a python script I use? If not, does anyone have one that will work for python?

Offline ZeroDX

  • Stealth Developer
  • Moderator
  • *****
  • Posts: 34
  • Activity:
    0%
  • Reputation Power: 1
  • ZeroDX has no influence.
  • Respect: +1
  • Referrals: 0
    • View Profile
Re: [C#] send texts
« Reply #2 on: September 09, 2018, 05:46:17 PM »
0
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

Tags: