Test mail cannot be sent at the same time as enabling PHPMailer

roderik - July 11, 2009 - 14:50
Project:PHPMailer
Version:6.x-2.x-dev
Component:Code
Category:bug report
Priority:normal
Assigned:Unassigned
Status:closed
Description

Upon configuring PHPMailer, if I
* check "Use PHPMailer to send e-mails"
* at the same time fill an e-mail address in the 'Test Configuration' textbox
and then press submit, processing stops and PHP gives an error
Call to undefined function drupal_mail_wrapper() in /data/www/drupal/6/includes/mail.inc on line 177
(after doing drupal_set_message('A test e-mail has been sent to %email ...)
-- which isn't true.)

The next time I visit the page admin/settings/phpmailer however, Drupal tells me again that it has sent the test e-mail. Which succeeds this time.

So I guess "registering drupal_mail_wrapper()" (or whatever it is this module does) is not done early enough in the process to be able to send the test mail for the first time.
(and the drupal_set_message() call should be moved tp after the drupal_mail() call . Or the text of the message changed.)

And this is not a disaster. Until it gets solved, this bug report is just there to tell people: the module does work; it's a one-time error (upon enabling it) only. You don't have to immediately start looking for patches on drupal.org, like I did :)

NB: I have no MIME mail module (or any other mail related handler modules) installed.

#1

roderik - July 11, 2009 - 20:57

Below is not the patch for the issue. It is just a patch for not getting the "a mail has been sent" if the mail wasn't actually sent.

I'm not going to solve the rest. Apparently what happens on submit is:
- phpmailer.module is included. Since the 'smtp_library' variable is not equal to "phpmailer", the function drupal_mail_wrapper() is not defined.
- phpmailer_settings_form() is called and
- defines the 'smtp_library' variable
- sees that a test mail should be sent, and calls a function that ends up at mail.inc:drupal_mail_send()

drupal_mail_send() does an 'include_once(phpmailer.module) which is NOT carried out, so drupal_mail_wrapper() is still undefined. And an error is thrown.

If this is worth fixing before D7 (where things will be different)? I'll leave that to someone who knows Drupal's bootstrap stuff better :)

AttachmentSize
516450.patch 852 bytes

#2

wonder95 - August 14, 2009 - 18:59

I get the exact same results as @roderik. As a suggestion, it seems to me that the better UI would be to have a submit button in the Test Configuration area or have it on another tab that sends the email by itself without having the save the configuration.

#3

sshvetsov - October 26, 2009 - 17:30

I have encountered the same error message as well. Found it very frustrating since at first I assumed that module installation failed or the module is not functioning properly.

#4

smk-ka - November 4, 2009 - 16:21
Status:active» fixed

This should be fixed in the latest development snapshot.

#5

System Message - November 18, 2009 - 16:30
Status:fixed» closed

Automatically closed -- issue fixed for 2 weeks with no activity.

 
 

Drupal is a registered trademark of Dries Buytaert.