Hi, so im doing my final year project for college and im thinking off adding a function whereby if it has reached the end of the month the system will send an automated email to a user as a reminder. is that possible? i mean coz im just using xampp, phpmyadmin and notepad++ so it possible?

Dani AI

Generated

A practical, low-friction approach for a XAMPP + Windows 7 setup (as in ) is: a small PHP script that detects the last day of the month and sends mail via an SMTP relay (using a library like PHPMailer), and a Windows Scheduled Task that runs the script once a day. This ties back to ’s scheduling point and keeps the local machine from having to act as a full mail server (a topic mentioned).

Below is a minimal pattern that does the date check and sends via SMTP (assumes PHPMailer installed via Composer):

<?php
require __DIR__ . '/vendor/autoload.php';
use PHPMailer\PHPMailer\PHPMailer;

$today = new DateTime('now', new DateTimeZone('UTC'));
if ($today->format('j') !== $today->format('t')) { exit; } // not last day

$mail = new PHPMailer(true);
try {
    $mail->isSMTP();
    $mail->Host = 'smtp.example.com';
    $mail->SMTPAuth = true;
    $mail->Username = 'smtp-user';
    $mail->Password = 'smtp-pass';
    $mail->SMTPSecure = 'tls';
    $mail->Port = 587;

    $mail->setFrom('noreply@example.com', 'App');
    $mail->addAddress('user@domain.com');
    $mail->Subject = 'Monthly reminder';
    $mail->Body    = 'This is the end-of-month reminder.';
    $mail->send();
} catch (Exception $e) {
    error_log('Monthly mail failed: ' . $mail->ErrorInfo);
}

For Task Scheduler: Program = C:\xampp\php\php.exe, Arguments = -f "C:\xampp\htdocs\project\send_monthly.php", Start in = project folder. Trigger = Daily (pick a time near midnight). Scheduling the PHP script daily and letting the script test for month-end avoids trying to express “last day” in the scheduler.

Notes and troubleshooting: use a local SMTP-capture tool when developing (Papercut or MailHog) to avoid sending real mail; store SMTP credentials outside the webroot or in environment variables; confirm PHP timezone (php.ini) so date math is correct; for production use a hosted cron or transactional SMTP relay (better deliverability) and add SPF/DKIM for the sending domain.

Recommended Answers

All 4 Replies

1) You can write php script which will send reminder according to current date, on which it runs.
2) schedule that script in windows or create cron job in linux to run it on last day of the month
3) you must already have one mail server configured to handle email messages

ok thanks for the tip. ill go look up how to configure an email server first. any questions will be posted.

im running a windows 7 ultimate and i read an article that says i have to install Remote Server Administration Tools that includes SMTP Server Tools for Windows 7. is that what i need to do, to be able to send an automated email for my final year project?

Member Avatar for Member #120589

If you're using xampp, then you have Mercury Mail - you could use that. However, if you have a hosted linux site, and they cost peanuts these days, you could set up a cron job (as mentioned) that runs a php script in the background. Mail admin is usually bundled in the deal. Much easier than phaffing with Windows and running your own mail server. However, if that aspect is part of your project, then I suppose you have no choice in the matter.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.