I'm done searching for tutorials of how to configure my Linux system to send e-mails via PHP. I hope you could help me..
So I have a valid webserver for a private website running on a Linux system. Now I want to send e-mails with a PHP-script over my SMTP email-account that came along with my domain.
I know I need some kind of mail transfer agent as referred in this thread. That's why I've already installed the package "sendmail". Moreover I need to edit the php.ini by adding some authentication entries. Because I'd like to give myself later the opportunity to send from multiple mail server for other projects, I would like to set my php.ini temporary by using ini_set() at the top of my config.php.
ini_set("SMTP", "smtp.mydomainhoster.com");
ini_set("sendmail_from", "me@mydomain.com");
ini_set("port", "465");
ini_set("auth_username", "me@mydomain.com");
ini_set("auth_password", "mypassword");
But surprise: s*** does not work. After a long time of page loading I get a positive result from mail()-call but the sent E-mail never arrived.
$to = 'nobody@example.com';
$subject = 'the subject';
$message = 'hello';
$headers = 'From: webmaster@example.com' . "\r\n" .
'Reply-To: webmaster@example.com' . "\r\n" .
'X-Mailer: PHP/' . phpversion();
mail($to, $subject, $message, $headers);
What have I done wrong? Is it the configuration?
Thank you so much for your help! I appreciate that!!