How to send SMS and email for free using Python

Português! English!

Enviando SMS e email gratuitos usando Python

Não importa se você quer criar um boletim informativo e enviá-lo para toda a sua lista de contatos ou se você só quer enviar SMS para alguns amigos, você pode fazer isso usando Python. É uma maneira simples e gratuita. Neste post, vou mostrar a você como fazer isso passo a passo. Estou usando isso para receber notificações sobre o status dos meus algoritmos. No entanto, quando o processo termina ou falha, recebo notificação sobre o status. Isso é realmente útil.

Se você quiser pegar o código, você pode encontrar todo o material no meu repositório.

Configurando o Ambiente Virtual

  1. Verifique se o Python está instalado no seu computador.
  2. Crie um ambiente virtual usando o seguinte comando:
     python -m venv .venv
    

    Você pode substituir “.venv” por um nome de ambiente diferente, se desejar. Mais informações neste website.

  3. Ative o ambiente virtual navegando até .venv\Scripts\activate.
  4. Uma vez que o ambiente virtual está ativado, você pode importar o pacote cliente de protocolo SMTP.

Configuração antes de enviar SMS e email

Agora que tudo está configurado, vamos enviar alguns emails e SMS. Eu usei GMAIL para enviar SMS e email. Então, eu preciso configurar o email para usar uma senha de aplicativo. Isso permitirá que você envie emails e SMS usando Python. Você pode encontrar mais informações nestes links:

Depois de criar, você precisa alterar o EMAIL e SENHA aqui e aqui.

Infelizmente, você precisa saber a operadora do telefone para o qual deseja enviar um SMS.

Enviando SMS e emails

Você pode usar uma abordagem .py ou um Jupyter Notebook para enviar o SMS e o e-mail. Ambos estão dentro deste repositório

  • Opção Jupyter Notebook: Todas as funções e dicas estão dentro deste Notebook. Apenas altere seus dados e tente.

  • Opção Python: Se você quiser executá-lo em uma escala maior, .py é uma boa opção. Você pode executar usando este arquivo python. Todas as configurações estão dentro deste arquivo.

Tudo isso está funcionando muito bem nos EUA; não tenho certeza de como adaptá-lo para diferentes países.

Sinta-se à vontade para explorar e modificar o código para atender às suas necessidades!


Português no começo!

Sending free SMS and email using Python

Doesn’t matter if you want to create a Newsletter and send it to all your contact list or if you just want to send SMS to some friends, you can do that using Python. It’s a simple and free way. In this post, I am going to show you how you can do it step-by-step. I am using this to receive notification about my algorithm’s status. However, the process ends or fails, I get notification about the status. It is really helpful.

If you want to cut the cake, you can find all this material at my repository.

Setting Up Virtual Environment

  1. Ensure Python is installed on your computer.
  2. Create a virtual environment using the following command:
     python -m venv .venv
    

    You can replace “.venv” with a different environment name if desired. More information in this website.

  3. Activate the virtual environment by navigating to .venv\Scripts\activate.
  4. Once the virtual environment is activated, you can import the SMTP protocol client package.

Configuration before sending SMS and email

Now everything is set up, let’s send some emails and SMS. I used GMAIL to send SMS and email. So, I need to configure the email to use an APP password. This will allow you to send emails and SMS using Python. You can find more information in these links:

After creating it, you need to change the EMAIL and PASSWORD here and here.

Unfortunately, you need to know the carrier from the phone you want to send an SMS.

Sending SMS and emails

You can use a .py approach or a Jupyter Notebook to send the SMS and e-mail. Both of them are inside this repository

  • Jupyter Notebook option: All the functions and tips are inside this Notebook. Just change for your data and give it a try.

  • Python option: If you want to run it on a larger scale, .py is a good option. You can run using this python file. All the configurations are inside this file.

All this is working just fine in the USA; not sure about how to adapt it for different countries.

Feel free to explore and modify the code to suit your needs!




Enjoy Reading This Article?

Here are some more articles you might like to read next:

  • How to Create QR Codes with Python
  • Working with Geotagged Photos
  • The problem of cloud cover
  • Displaying External Posts on Your al-folio Blog