How can a local mail server without a domain be set up to send emails to external addresses like @t-online.de?

To send emails to external addresses like @t-online.de from a local mail server without a domain, you can configure the mail server to use a relay host provided by your internet service provider. This relay host will act as an intermediary for sending emails to external domains. You will need to update the mail server configuration to use the relay host's SMTP server and possibly authenticate with credentials.

<?php
$to = 'recipient@t-online.de';
$subject = 'Test Email';
$message = 'This is a test email sent from a local mail server without a domain.';
$headers = 'From: sender@example.com' . "\r\n" .
    'Reply-To: sender@example.com' . "\r\n" .
    'X-Mailer: PHP/' . phpversion();

$mail_sent = mail($to, $subject, $message, $headers);

if($mail_sent) {
    echo 'Email sent successfully!';
} else {
    echo 'Email sending failed.';
}
?>