Test der php mail() -Funktion auf Server

  • 0 Antworten
  • Letztes Antwortdatum
say_hello

say_hello

Dauer-User
267
Hi Community, guten Abend,

ich teste soeben die allgem. Fähigkeiten des Mailversands auf dem Server. - und ohne gleich nun auf smtp auszuweichen - dachte ich, teste doch mal die php-Mail-Funktionalität. Also - nebenbei bemerkt: ich hab auf dem Server gecheckt wie die Serverdaten so aussehen: php.ini: The php.ini hat smtp_port = 25 set Aber für den schlichten Test der Basismailfunktionen des Servers für diesen Test brauche ich diese (n) smtp_port = 25 set nicht.

unten mehrere Skripte die ich getestet habe mit den resultaten


mailtest10.php: Testresultat: email sent - aber es kam keine Mail in meiner inbox an.

von hier: Simple PHP Mail test • Conetix

Code:
<?php
    ini_set( 'display_errors', 1 );
    error_reporting( E_ALL );
    $from = "My_testmai_adress_@mywebserver.com";
    $to = "My_testmai_adress_@mywebserver.com";
    $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: Testresultat: Error: Message not accepted

von hier: How to test and fix the php mail() function

Code:
<?PHP
$sender = 'My_testmai_adress_@mywebserver.com';
$recipient = 'My_testmai_adress_@mywebserver.com';

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

if (mail($recipient, $subject, $message, $headers))
{
    echo "Message accepted";
}
else
{
    echo "Error: Message not accepted";
}
?>




<<<<<<<

mailtest30.php: Test-results: Testing PHP mail - dieser Text wurde angezeigt! Aber es kam keine Mail an.

von hier: PHP Mail Script for Testing Email Sending | Tek Eye

Code:
<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="utf-8" />
        <title>PHP Mail Test</title>
    </head>
    <body>
        <h1>Testing PHP mail</h1>
        <?php
            //Use your test email address
            $to      = 'My_testmai_adress_@mywebserver.com';
            //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: some.body@example.com';
            //Send the email
            if(mail($to, $subject, $message, $headers))
            {
                echo 'Email sent out';
            }
            else
            {
                echo '<pre>';
                print_r(error_get_last());
                echo  '</pre>';
            }
        ?>
    </body>
</html>


<<<<<

mailtest40.php:Testresultat: access denied: dieser Text wurde angezeigt

von hier: PHP mail function doesn't complete sending of e-mail

Code:
<?php
$name = $_POST['name'];
$email = $_POST['email'];
$message = $_POST['message'];
$from = 'From: yoursite.com';
$to = 'My_testmai_adress_@mywebserver.com';
$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: from@example.com' . "\r\n" .
'Reply-To: reply@example.com' . "\r\n" .
'X-Mailer: PHP/' . phpversion();

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

<<<<<<


mailtest50.php: Test-results: access denied-this: dieser T ext wurde angegezeigt

von hier : How to check if PHP mail() is enabled?

Code:
<?php

$email = "My_testmai_adress_@mywebserver.com";
$subject =  "Email Test";
$message = "this is a mail testing email function on server";


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

{
echo "Mail Failed";
}
?>

Ich denke dass ich nun mal nach den basalen Einstellungen des SERVERs sehe und guck was hier nicht korrekt läuft.

Hab hier noch eine nette Checkliste gefunden mit tipps u. Iddeen auf was man hier noch achten sollte. PHP mail function doesn't complete sending of e-mail



update:
es gibt sicherheitslücken in mail ()

cf Why mail() is dangerous in PHP


Why mail() is dangerous in PHP....that based on insecure usage of the PHP mail()
function. ...these vulnerabilities and how to use mail() securely.

summary:
..we have highlighted the risks of the 5th mail() parameter and how to protect
against attacks that can result in full server compromise.


ich verwende diesen smtp-plugin: WP Mail SMTP von WPForms

damit läuft alles ganz gut-
 
Zuletzt bearbeitet:
Zurück
Oben Unten