Skip to content

NafTasmi/Gmail-Send

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

3 Commits
Β 
Β 
Β 
Β 

Repository files navigation

Email Sender Script

A simple Python script to send emails using Gmail's SMTP server.

πŸ“‹ Prerequisites

  • Python 3.x installed
  • A Gmail account
  • App Password (not your regular Gmail password)

πŸ”§ Setup

1. Enable 2-Factor Authentication on Gmail

  • Go to your Google Account settings
  • Enable 2-Step Verification

2. Generate App Password

  1. Visit: https://myaccount.google.com/apppasswords
  2. Select "Mail" as the app
  3. Select your device
  4. Generate and copy the 16-character app password

3. Install Required Library

No additional installation required - uses Python's built-in smtplib library.

πŸš€ Usage

  1. Edit the script with your credentials:

    gmail_user = "your_email@gmail.com"
    gmail_password = "your_app_password_here"
  2. Update recipient email:

    to = ["recipient@example.com"]
  3. Run the script:

    python email_sender.py

⚠️ Security Notes

⚠️ IMPORTANT: Never commit this script with real credentials to version control.

  • Remove or replace credentials before sharing
  • Use environment variables for production
  • Consider using .env files for local development

πŸ“ Code Features

  • Secure SSL connection to Gmail SMTP (port 465)
  • Basic error handling
  • Simple email formatting
  • Console feedback for success/failure

πŸ› οΈ Troubleshooting

Common issues and solutions:

  1. Authentication Error: Ensure you're using an App Password, not your regular Gmail password
  2. Connection Refused: Check firewall settings or try enabling "Less secure app access" (deprecated)
  3. Email Not Received: Check recipient's spam folder

πŸ”’ Recommended Security Practices

For production use, consider:

  • Using environment variables
  • Implementing a configuration file
  • Adding input validation
  • Using email templates for complex emails

πŸ“„ License

This script is for educational purposes. Use responsibly and in compliance with Gmail's terms of service.

About

This Python code sends a simple email through Gmail's SMTP server using SSL authentication and includes error handling for the sending process.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages