Hello,

i've got a problem and can't figure out how to solve it. I'm not sure whether it is a bug or if I did something wrong with the configuration. So I file this support request here.

I use Views Send to send E-Mails to selected users from a view. This is working very well.

The problem is that I don't want to use the mailserver on localhost but a specified SMTP server.

I use the SMTP module to set up a connection to the desired SMTP server and use the Mailsystem module to define the system-wide mailsystem as "SMTP module" and tell Views Send and MIME Mail to use the SMTP module aswell.

But Views Send is still sending mails using the machine on localhost.

How to use Views Send to send mails to a specified SMTP server?

Cheers
donSchoe

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

donSchoe’s picture

Title: Views Send does not use Mailsystem/SMTP modules configuration » Views Send overrides Mail System module configuration
Component: Miscellaneous » Code
Category: support » bug

Okay, after some playing round with the three mentioned modules I've found out that setting the Views Send default mailing system using the Mailsystem module gets reset after each Cron run to MIME Mail.

Custom mailsystem filters like MimeMailSystem_SmtpMailSystem will be overriden and it's impossible to send mails via SMTP module.

Is there a way to fix this that Views Send works together with the Mailsystem/SMTP modules?

hansfn’s picture

Status: Active » Postponed (maintainer needs more info)

Thx for your report.

I haven't really touched this part of the code after I took over this module - I normally send plain text email ;-) Anyway, it's a fact that this module is/was very MIME Mail centric.

The overriding happens in the function views_send_deliver in views_send.module. (It's not cron specific.) I wonder if the call to "mailsystem_set" is really needed? Please test and provide a patch if you have general solution. I haven't time right now to look more at this.

donSchoe’s picture

Assigned: Unassigned » donSchoe
Status: Postponed (maintainer needs more info) » Active

I just found the snipped of code, too.

    mailsystem_set(array(
      "views_send_$key" => 'MimeMailSystem'
    ));

I'll try to find a solution and keep you up to date.

donSchoe’s picture

Version: 7.x-1.0-rc3 » 7.x-1.x-dev
Assigned: donSchoe » Unassigned
Status: Active » Needs review
FileSize
1.72 KB

This patch does the trick for me. It does not call mailsystem_set() directly anymore.

I created a wrapper function _views_send_mailsystem_set() which checks for the availability of the mailsystem module and if it exists, uses the mailsystem settings instead of the default Views Send settings.

If no mailsystem module is available, nothing changes.

Please, review this patch. Thanks!

pipep’s picture

Thanks donSchoe your patch did the trick for me !

donSchoe’s picture

Status: Needs review » Reviewed & tested by the community
hansfn’s picture

Status: Reviewed & tested by the community » Active
FileSize
870 bytes

The patch has numerous issues because:

  1. The call to mailsystem_set (or your new function) is only done if the mimemail module is enabled (VIEWS_SEND_MIMEMAIL is true).
  2. The mimemail module has the mailsystem module as a dependency.

So, to be specific:

  • This means that the check for mailsystem module is completely unnecessary. If it was necessary and the mailsystem module wasn't enabled, the call to mailsystem_set would fail since that function is part of mailsystem.
  • The check for VIEWS_SEND_MIMEMAIL is unnecessary since the function only is called if VIEWS_SEND_MIMEMAIL is true.
  • Most importantly, you use the variable $key which isn't set in the function which means that you define the mailsystem "views_send_", not "views_send_direct". In other words, Views Send will use the default mailsystem when drupal_mail is called. You could have just removed the mailsystem_set call in stead of your patch. (Please test and verify this.)

I have attached a minimal patch that does correctly what you intended. However, I wonder if the best fix is to just use the default mailsystem - remove the call to mailsystem_set?

donSchoe’s picture

Assigned: Unassigned » donSchoe
Status: Active » Needs review

Ok, that's some usefull hints.

  1. I wasn't aware of the mimemail dependency with mailsystem. The check for mailsystem module is not needed indeed.
  2. I think the mailsystem_set is needed to ensure that HTML-formatted mails are formatted using mimemail. If this is not called it could be possible, views_send would not use any format() module.
  3. The double-check for minemail was because if I call that helper function _views_send_mailsystem_set() from another location in future, I will not know if the check is included, but yeah, your approach looks much smarter.

I will test the patch later. On first glance it looks pretty good as it adresses the problem with overriding user sittings in mailsystem with the mailsystem_get() function.

donSchoe’s picture

Status: Needs review » Reviewed & tested by the community

Patche applied cleanly on 7.x branch.

views_send# git apply -v mailsystem-integration-2023977-7.patch
Checking patch views_send.module...
Applied patch views_send.module cleanly.

Tested & confirmed: The module now works as desired, no settings in mailsystem wont be overridden and sending mails through SMTP module is now possible.

Nice patch! :)

hansfn’s picture

Assigned: donSchoe » hansfn

Thx for testing.

I'm leaving on holiday tomorrow, but if I have some spare time (with Wifi) I'll commit it before I'm back. If not, I'll do it the 15th of July.

hansfn’s picture

Status: Reviewed & tested by the community » Fixed

Fixed in commit a2fdd46.

donSchoe’s picture

thanks hansfn :)

Status: Fixed » Closed (fixed)

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

Anonymous’s picture

Version: 7.x-1.x-dev » 7.x-1.0-rc3
Category: Bug report » Support request
Issue summary: View changes
Status: Closed (fixed) » Active

It looks like this fix was never pushed to a "recommended release". Fyi, I am using 7.x-1.0-rc3.

As background, I use a combination of Mail System and SwiftMailer, and my Views Send mails are bitten by the problem reported here.

Does anyone know if there is a suitable patch for this to 7.x-1.0-rc3?

Also, is 7.x-1.x-dev stable? And does it address this issue such that the Mail System / SwiftMailer combination will work as intended?

Views Send is a very handy module, by the way. It meets needs that are not really suited to Simplenews (and other mailing list solutions).

Thanks in advance for your answers to my questions,

Bob

hansfn’s picture

Status: Active » Closed (fixed)

Hi, Bob.

You are right, the issue isn't fixed in 7.x-1.0-rc3. I have forgotten to create a new release.

Anyway, it's completely safe to use the current 7.x-1.x-dev version. Please try the dev version, and create a new issue if it doesn't work, because then the problem is related to SwiftMailer.

I'll try to create a new release later this week. Maybe 7.x-1.0 ;-)

Anonymous’s picture

Thanks, Hans.

I will keep you posted if there is an issue.

Bob