What is the recommended method for sending emails in PHP on All-inkl. webspace?

When sending emails in PHP on All-inkl. webspace, it is recommended to use the SMTP method with authentication for better reliability and security. This involves setting up the SMTP server, username, password, and port in your PHP code to send emails successfully.

// Set SMTP settings
ini_set('SMTP', 'mail.example.com');
ini_set('smtp_port', 587);
ini_set('sendmail_from', 'your_email@example.com');
ini_set('auth_username', 'your_email@example.com');
ini_set('auth_password', 'your_password');

// Send email
$to = 'recipient@example.com';
$subject = 'Test Email';
$message = 'This is a test email.';
$headers = 'From: your_email@example.com';

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