John Davidson

php - Adding new datas to the email


The code below checks the "Paid" reservations from the database and sends them as an email with a cron job.

Normally only "pay_url" data is added from the database, yet I'd like to add "customer_name", "customer_surname" and "amount" along with pay_url.

Could you please guide me on how to do it?

Thank you in advance.

include "../lib/include.php";

$yesterdayDate = date("Y-m-d 09:00:00", strtotime("-1 days"));
$query = "select * from links where status = 1 and cc_payment_id != '' and payment_date >= '".$yesterdayDate."' and payment_date <= '".date("Y-m-d 08:59:59")."'";

$q = $db->query($query);
foreach ($q AS $a) {

$mail_content .= "".$a["pay_url"]." -> Paid<br>";

if ($mail_content != "") {
SendMail($settings["system_email"],$mail_content,"Paid Reservations");

My Answer:
validity of an email address and adds new data to it:


$email = "[email protected]";

// Check if email is valid
if (filter_var($email, FILTER_VALIDATE_EMAIL)) {
// Add new data to email
$newData = "123";
$newEmail = $email . $newData;

echo "New email with added data: " . $newEmail;
} else {
echo "Invalid email address";


This code first checks if the email address is valid using the `FILTER_VALIDATE_EMAIL` filter. If the email is valid, it adds new data to the email address and prints out the new email with the added data. If the email is not valid, it prints out "Invalid email address".

Rate this post

3 of 5 based on 7053 votes


© 2024 - Personal Blogs Platform. All Rights Reserved.
Create blog  |  Privacy Policy  |  Terms & Conditions  |  Contact Us