Set up email sender on a cloud server
by Pedroski from LinuxQuestions.org on (#5RP3N)
I am very new to setting up a cloud server.
On my shared hosting webpages, I suppose email is set up already, my contact page sends me a message, no problem.
I have set up the contact page on the cloud server, it opens as it should.
What do I need to enable PHP to send an email on this Ubuntu 20.04 Server?
What do I need to install?
On the shared hosting, this little bit of PHP works fine.
Code:<?php
$q1 = $_POST['name'];
$q2 = $_POST['email'];
$q3 = $_POST['message'];
$body = "
".$q1."
".$q2."
".$q3."
";
$to1 = "me@mymail.com";
$subject = $q1 . " message";
$headers = "From: peter@mywebpage.com\r\n";
$headers .= 'Content-Type: text/plain; charset=utf-8';
mail($to1, $subject, $body, $headers);
?>
On my shared hosting webpages, I suppose email is set up already, my contact page sends me a message, no problem.
I have set up the contact page on the cloud server, it opens as it should.
What do I need to enable PHP to send an email on this Ubuntu 20.04 Server?
What do I need to install?
On the shared hosting, this little bit of PHP works fine.
Code:<?php
$q1 = $_POST['name'];
$q2 = $_POST['email'];
$q3 = $_POST['message'];
$body = "
".$q1."
".$q2."
".$q3."
";
$to1 = "me@mymail.com";
$subject = $q1 . " message";
$headers = "From: peter@mywebpage.com\r\n";
$headers .= 'Content-Type: text/plain; charset=utf-8';
mail($to1, $subject, $body, $headers);
?>