How can a database be sent via email using PhpMyAdmin?

To send a database via email using PhpMyAdmin, you can export the database as a SQL file and then attach it to an email using PHP's mail function. The SQL file can be generated by selecting the database in PhpMyAdmin, clicking on the Export tab, and choosing the SQL format.

<?php
$to = "recipient@example.com";
$subject = "Database Backup";
$message = "Please find attached the database backup.";
$attachment = "/path/to/your/database.sql";

// Read the file content
$file_content = file_get_contents($attachment);

// Set the email headers
$headers = "From: sender@example.com\r\n";
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-Type: text/plain; charset=UTF-8\r\n";
$headers .= "Content-Disposition: attachment; filename=database.sql\r\n";

// Send the email with attachment
mail($to, $subject, $message, $headers, $file_content);
?>