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,223 32,723 1 hour ago
Last Post: theram123
  [FREE] CRTO I and II - Red Team Ops lessons by Zero-Point Security Tamarisk 1,704 149,024 3 hours ago
Last Post: sabbyahmed
  [FREE] Retired Offensive Security OSWE / WEB-300 exam writeups Tamarisk 1,062 85,218 3 hours ago
Last Post: wizard_not_found
  TOP SECRET DOCUMENTS LEAKED OF NSA,FBI.,CIA,UFO,ARMY lulagain 523 15,948 3 hours ago
Last Post: sabbyahmed
  Top Telegram Channels list [2025] j3n1n 3,106 62,613 3 hours ago
Last Post: godjimax

Forum Jump:


 Users browsing this forum: 1 Guest(s)