How can a PHP script be structured to check server connections and send emails with automatic link opening?

To check server connections and send emails with automatic link opening in PHP, you can use the `fsockopen()` function to check server connections, and the `mail()` function to send emails with HTML content containing automatic link opening. Here is a PHP code snippet that demonstrates this:

<?php
// Check server connection
$server = 'www.example.com';
$port = 80;
if ($fp = @fsockopen($server, $port, $errno, $errstr, 30)) {
    echo "Server connection successful!";
    fclose($fp);
} else {
    echo "Server connection failed: $errstr ($errno)";
}

// Send email with automatic link opening
$to = 'recipient@example.com';
$subject = 'Test Email';
$message = '<html><body><p>This is a test email with <a href="http://www.example.com">automatic link opening</a>.</p></body></html>';
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$headers .= 'From: sender@example.com' . "\r\n";

mail($to, $subject, $message, $headers);
?>