White Screen of Death upon sending test email

Created on 1 May 2023, about 1 year ago
Updated 2 May 2023, about 1 year ago

Problem/Motivation

i have drupal 10, and latest php 8.2.5, fresh installaiton, and installed all required modules, via composer ofcourse.
but failing to send email

getting this error:

[01-May-2023 11:58:10 Asia/Dubai] Uncaught PHP Exception Error: "Call to a member function fromArray() on null" at D:\wamp64\www\backoffice_drupal_seo_wamp\web\modules\contrib\symfony_mailer\src\MailManagerReplacement.php line 89
[01-May-2023 12:02:57 Asia/Dubai] Uncaught PHP Exception Error: "Call to a member function fromArray() on null" at D:\wamp64\www\backoffice_drupal_seo_wamp\web\modules\contrib\symfony_mailer\src\MailManagerReplacement.php line 89
[01-May-2023 12:04:49 Asia/Dubai] Uncaught PHP Exception Error: "Call to a member function fromArray() on null" at D:\wamp64\www\backoffice_drupal_seo_wamp\web\modules\contrib\symfony_mailer\src\MailManagerReplacement.php line 89
[01-May-2023 12:07:34 Asia/Dubai] Uncaught PHP Exception Error: "Call to a member function fromArray() on null" at D:\wamp64\www\backoffice_drupal_seo_wamp\web\modules\contrib\symfony_mailer\src\MailManagerReplacement.php line 89
[01-May-2023 12:11:29 Asia/Dubai] Uncaught PHP Exception Error: "Call to a member function fromArray() on null" at D:\wamp64\www\backoffice_drupal_seo_wamp\web\modules\contrib\symfony_mailer\src\MailManagerReplacement.php line 89
[01-May-2023 12:13:28 Asia/Dubai] Uncaught PHP Exception Error: "Call to a member function fromArray() on null" at D:\wamp64\www\backoffice_drupal_seo_wamp\web\modules\contrib\symfony_mailer\src\MailManagerReplacement.php line 89
[01-May-2023 12:14:30 Asia/Dubai] Uncaught PHP Exception Error: "Call to a member function fromArray() on null" at D:\wamp64\www\backoffice_drupal_seo_wamp\web\modules\contrib\symfony_mailer\src\MailManagerReplacement.php line 89
[01-May-2023 12:17:19 Asia/Dubai] Uncaught PHP Exception Error: "Call to a member function fromArray() on null" at D:\wamp64\www\backoffice_drupal_seo_wamp\web\modules\contrib\symfony_mailer\src\MailManagerReplacement.php line 89
[01-May-2023 12:17:29 Asia/Dubai] Uncaught PHP Exception Error: "Call to a member function fromArray() on null" at D:\wamp64\www\backoffice_drupal_seo_wamp\web\modules\contrib\symfony_mailer\src\MailManagerReplacement.php line 89

Steps to reproduce

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

✨ Feature request
Status

Closed: works as designed

Version

2.2

Component

Code

Created by

πŸ‡―πŸ‡΄Jordan bmustafa

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @bmustafa
  • Status changed to Postponed: needs info about 1 year ago
  • πŸ‡¦πŸ‡ΊAustralia imclean Tasmania

    It looks like you've installed Symfony Mailer at some point. PHPMailer SMTP doesn't require Symfony Mailer, and Symfony Mailer doesn't require this module. They both perform similar functions.

    Pick one email module and uninstall the other.

    I'll leave this open for now in case you have anything further to add.

  • πŸ‡―πŸ‡΄Jordan bmustafa

    Yes i have disabled that per your advice, not sure why i got it enabled earlier.
    however, the authentication fails with gmail, despite user name and password are correct.
    i do not see that this module supports Oauth2 yet, can you please implement it, it is not difficult:

    1. Install the latest version of PHPMailer using Composer:
    2. composer require phpmailer/phpmailer
    3. Install the Gmail API client library using Composer:
    4. composer require google/apiclient:^2.0
    5. Obtain the OAuth2 credentials for your Gmail account using the Gmail API client library.
    6. Use the obtained credentials to authenticate PHPMailer with OAuth2 and send an email.

    Here is the sample code to send email using PHPMailer with OAuth2 authentication:

    
    require_once 'vendor/autoload.php';
    
    use PHPMailer\PHPMailer\PHPMailer;
    use PHPMailer\PHPMailer\OAuth;
    use Google\Client;
    use Google\Service\Gmail;
    
    // Replace placeholders with actual values
    define('CLIENT_SECRET_PATH', 'path/to/client_secret.json');
    define('CREDENTIALS_PATH', 'path/to/credentials.json');
    define('EMAIL_FROM', 'YOUR_EMAIL_ADDRESS_HERE');
    define('NAME_FROM', 'YOUR_NAME_HERE');
    define('EMAIL_TO', 'RECIPIENT_EMAIL_ADDRESS_HERE');
    define('NAME_TO', 'RECIPIENT_NAME_HERE');
    define('EMAIL_SUBJECT', 'EMAIL_SUBJECT_HERE');
    define('EMAIL_BODY', 'EMAIL_BODY_HERE');
    
    // Set up the Google API client
    $client = new Client();
    $client->setApplicationName('My Application Name');
    $client->setScopes([Gmail::GMAIL_READONLY]);
    $client->setAuthConfig(CLIENT_SECRET_PATH);
    $client->setAccessType('offline');
    $client->setPrompt('select_account consent');
    
    // Create a new Gmail API client instance
    $gmail = new Gmail($client);
    
    // Obtain the OAuth2 credentials for your Gmail account
    $authUrl = $client->createAuthUrl();
    echo "Please visit this URL to authorize the application: $authUrl\n";
    $authCode = readline("Enter the authorization code: ");
    $accessToken = $client->fetchAccessTokenWithAuthCode($authCode);
    
    // Store the credentials for later use
    file_put_contents(CREDENTIALS_PATH, json_encode($accessToken));
    
    // Create a new instance of PHPMailer
    $mail = new PHPMailer();
    
    // Set the SMTP settings for Gmail
    $mail->isSMTP();
    $mail->Host = 'smtp.gmail.com';
    $mail->SMTPAuth = true;
    $mail->SMTPSecure = 'tls';
    $mail->Port = 587;
    
    // Set the OAuth2 authentication settings
    $mail->setOAuth(
        new OAuth([
            'clientId' => $client->getConfig('client_id'),
            'clientSecret' => $client->getConfig('client_secret'),
            'refreshToken' => $accessToken['refresh_token'],
            'userName' => EMAIL_FROM,
        ])
    );
    
    // Set the email message properties
    $mail->setFrom(EMAIL_FROM, NAME_FROM);
    $mail->addAddress(EMAIL_TO, NAME_TO);
    $mail->Subject = EMAIL_SUBJECT;
    $mail->Body = EMAIL_BODY;
    
    // Send the email
    if (!$mail->send()) {
        echo 'Message could not be sent.';
        echo 'Mailer Error: ' . $mail->ErrorInfo;
    } else {
        echo 'Message sent successfully';
    }
    
    

    Make sure to replace the placeholder values with your actual credentials and message details before running the code.

  • Status changed to Closed: works as designed about 1 year ago
  • πŸ‡¦πŸ‡ΊAustralia imclean Tasmania

    @bmustafa have a look at PHPMailer OAuth2 β†’ and see how that integrates with this module, you can add your own provider there.

    Have a look at the issues for that module, including ✨ PHPMailer OAuth2 - Add support for Google's XOAuth2 Active .

Production build 0.69.0 2024