check the basic mail functions on a server

If it doesn't relate to Debian, but you still want to share it, please do it here

check the basic mail functions on a server

Postby say_hello » 2021-01-15 15:13

hi there dear folks

currenty work out some issues i have on a server. I need to check the basic mail functions... i have issues here

by the way and on a sidenote: i also checked some things in the php.ini: The php.ini has smtp_port = 25 set
but this function - we do not need for our checks... at the moment. .

below some of the tests - / note i tested some scripts -... all of them see below - with the results

mailtest10.php: Test-results: email sent - but no mail received at my inbox
taken from:

Code: Select all
    ini_set( 'display_errors', 1 );
    error_reporting( E_ALL );
    $from = "";
    $to = "";
    $subject = "PHP Mail Test script";
    $message = "This is a test to check the PHP Mail functionality";
    $headers = "From:" . $from;
    mail($to,$subject,$message, $headers);
    echo "Test email sent";


mailtest20.php: Test-results: Error: Message not accepted

taken from: ... ction.html

Code: Select all
$sender = '';
$recipient = '';

$subject = "php mail test";
$message = "php test message";
$headers = 'From:' . $sender;

if (mail($recipient, $subject, $message, $headers))
    echo "Message accepted";
    echo "Error: Message not accepted";


mailtest30.php: Test-results: Testing PHP mail - this text was shown up

taken from: ... il-sending

Code: Select all
<!DOCTYPE html>
<html lang="en">
        <meta charset="utf-8" />
        <title>PHP Mail Test</title>
        <h1>Testing PHP mail</h1>
            //Use your test email address
            $to      = '';
            //Use an appropriate email subject
            $subject = 'A Test Email';
            $message = 'The quick brown fox jumped over the lazy dog. Then the fox jumped over the dog again.';
            //wordwrap long content
            $message = wordwrap($message, 70, "\r\n");
            $headers = 'From:';
            //Send the email
            if(mail($to, $subject, $message, $headers))
                echo 'Email sent out';
                echo '<pre>';
                echo  '</pre>';


mailtest40.php:Test-results: access denied-this text was shown up

taken form here: ... -of-e-mail

Code: Select all
$name = $_POST['name'];
$email = $_POST['email'];
$message = $_POST['message'];
$from = 'From:';
$to = '';
$subject = 'Customer Inquiry';
$body = "From: $name\n E-Mail: $email\n Message:\n $message";

$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-type: text/html\r\n";
$headers .= 'From:' . "\r\n" .
'Reply-To:' . "\r\n" .
'X-Mailer: PHP/' . phpversion();

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


mailtest50.php: Test-results: access denied-this text was shown up!

taken from: ... is-enabled

Code: Select all

$email = "";
$subject =  "Email Test";
$message = "this is a mail testing email function on server";

$sendMail = mail($email, $subject, $message);
echo "Email Sent Successfully";

echo "Mail Failed";


Well - now i will have a closer look at the server-conditions.

btw - besides the various scripts i found some other ressoruces that cover the topic-mail-deliverability and sending mails from a server: here i found a with explanaitions ... -of-e-mail

interesting points here are some of the following:
Make sure mail headers have no syntax errors
Enable PHP's custom mail.log
See for details. (It's best to enable these options in the php.ini or .user.ini or .htaccess perhaps.)
Make sure your form action value points to the correct location[/quote]

see more here: ... -of-e-mail

Look forward to hear from you..

User avatar
Posts: 26
Joined: 2019-10-13 09:58

Re: check the basic mail functions on a server

Postby reinob » 2021-01-16 13:21

From your message it's not clear what your problem or question is.
If you want to send e-mails from php using the mail() function then you need to have an e-mail server running at your web server.
mail() by default calls /usr/sbin/sendmail.

The most common option is to install postfix and configure it properly.

Given that you mention smtp_port I'm not sure if you're even running Linux at all, so I'd recommend you clear up first what you want to actually do, whether your server runs Linux or Windows (which uses the smtp_port option), and of course how you plan to configure your e-mail server.

It is very easy to get things wrong and end up being a spam source/relay, which in turn will land you in one or more blacklists.
Posts: 900
Joined: 2014-06-30 11:42

Return to Offtopic

Who is online

Users browsing this forum: No registered users and 9 guests