Topic: PHP mail() not sending emails on mdbgo.io

PieterSA free asked 3 years ago


Expected behavior

  • Mail sent successfully with: mail($email, $subject, $message, $headers);

Actual behavior

  • Mail not sent at all with: mail($email, $subject, $message, $headers);

  • Mail function doesn't seem to work, I followed the code example at https://www.youtube.com/watch?v=XHwPKdfIXMg\

  • My MDB CLI version is 3.3.0 (3.3.0 is not available to select on the form above) and PHP version is 8.0.6 (I had to publish as 7.4 as 8 is not available)

  • On my localhost mail IS sent successfully, using Mercury & fake email. But on mdbgo.io it doesn't work and I get no error messages to know what is wrong.

  • I tried different headers and all kinds of other stuff, please see below for headers:

  • (UPDATE 2021-05-16 14:25: I installed PHPMailer and got it to work with Gmail's SMTP service. Settings: Host:smtp.gmail.com, SMTPSecure: ssl, Port: 465 & SMTPAuth: true. On my Gmail account, I had to enable Two-step verification and create an App password which I then plugged in as my gmail account password for the credentials.)

  • I'm happy with this but if you guys have another way I can send emails using your server please let me know. Thanks!

Resources (screenshots, code snippets etc.)

My error message on mdbgo.io

    <?php
    require_once 'connection.inc.php';

    $subject = $_POST['subject'];
    $body = $_POST['body'];
    // Tried different versions of this first:
    $headers = "From: Newsletter No Reply <noreply@newsletter.mdbgo.io>\n";
    $headers .= "Reply-To: Newsletter <news@newsletter.mdbgo.io>\n";
    $headers .= "Content-Type: text/plain; charset='iso-8859-1'\n";
    $headers .= "Content-Transfer-Encoding: 8bit\n";

    // Tried this:
    // $headers = "From: Newsletter No Reply <noreply@newsletter.mdbgo.io>\r\n";
    // $headers .= "Reply-To: Newsletter <news@newsletter.mdbgo.io>\r\n";
    // $headers .= "X-Mailer: PHP/" . PHP_VERSION;

    // Tried this:
    // $headers = array("From: noreply@newsletter.mdbgo.io",
    //     "Reply-To: news@newsletter.mdbgo.io",
    //     "X-Mailer: PHP/" . PHP_VERSION;
    // );
    // $headers = implode("\r\n", $headers);

    // Tried this:
    // $headers = "From: noreply@newsletter.mdbgo.io" . "\r\n";
    // $headers .= "MIME-Version: 1.0" . "\r\n";
    // $headers .= "Content-type:text/html;charset=UTF-8" . "\r\n";

    // Tried this:
    // $headers[] = 'MIME-Version: 1.0';
    // $headers[] = 'Content-type: text/html; charset=iso-8859-1';
    // $headers = implode("\r\n", $headers);

    // Lastely tried this:
    // $headers = array(
    //     "From: noreply@newsletter.mdbgo.io",
    //     "Reply-To: news@newsletter.mdbgo.io",
    //     "Content-Type: text/plain; charset=iso-8859-1",
    //     "Content-Transfer-Encoding: 8bit"
    // );
    // $headers = implode("\r\n", $headers);

    // Rest of my code:
    $query = "SELECT * from $table";
    $result = $dbc->query($query)
        or die ("Error querying database... " . $dbc->error);

    while ($row = mysqli_fetch_array($result, MYSQLI_BOTH))
    {
        $first_name = $row["first_name"];
        $last_name = $row["last_name"];
        $email = $row["email"];

        $message = "Dear $first_name $last_name, \n $body";

        if(mail($email, $subject, $message, $headers)){
            echo "Email sent to: $email";
        }
        else {
            echo "MESSAGE: Failed to send email to: $email";
        }
    }
    ?>


Sebastian Kaczmarek staff answered 3 years ago


Hi, sorry for the inconvenience. We are aware of this problem and are working on it. Currently, your solution is the only working one. But as I said we are trying to solve it so that mail() could work.


PieterSA free commented 3 years ago

Thank you for your response, I'm looking forward to see it working again!



Please insert min. 20 characters.

FREE CONSULTATION

Hire our experts to build a dedicated project. We'll analyze your business requirements, for free.

Status

Answered

Specification of the issue

  • ForumUser: Free
  • Premium support: No
  • Technology: MDB CLI / MDB GO
  • MDB Version: 3.2.7
  • Device: PC Desktop
  • Browser: Google Chrome (latest)
  • OS: Windows 10 (latest)
  • Provided sample code: Yes
  • Provided link: Yes