Still new at posting issues so if this isn't in the right format/procedure be forgiving.

Basically -- I was trying to create a new class to use: HTMLMailSystem__SMTPMailSystem

When I was initially creating the class, I was getting temporary file could not be copied type of error, went and checked through things, saw the tmp inc file being created for the class, but it wasn't being copied. Digging into the module deeper, on line 135 of mailsystem.module I discovered the line of code that was being the problem: $class_dir = file_build_uri('mailsystem');

The file_build_uri creates something like public:// or private://, however in my case with the S3FS module being used it was creating "s3://HTMLMailSystem__SmtpMailSystem.mail.inc", which down the line on line 177 ( if (file_unmanaged_save_data($class_contents, $class_file, FILE_EXISTS_REPLACE)) { ), $classfile was simply "/HTML.....mail.inc", which wouldn't fly obviously.

I was able to force it to work for my purposes by forcing $class_dir = 'private://mailsystem';

It worked and its in the registry for me now and works for what I need and its stored in the registry so it shouldn't resurface for me - but is there some method of reworking where it places the file or what default scheme it uses?

CommentFileSizeAuthor
#7 mailsystem-n2687265-7.patch2.01 KBDamienMcKenna
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Rhane created an issue. See original summary.

N20’s picture

We are using s3fs as well and it's a big mess with these files created by mailsystem.

You could use try using mailsystem-7.x-3.0-alpha1 or as i did 7.x-3.x-dev. Both do not need any files at all.

But be aware of this: https://www.drupal.org/node/2700547

I still had plenty struggles with both version. Theme was broken and the site slowed down a lot read here and here. Also a class was missing (can't find the patch for that right now).

terrylb’s picture

We're having this same issue too except when trying to create a new class of MIMEMailSystem_SmtpMailSystem. It returns the error:

File temporary://file2Gqcq2 could not be copied, because the destination directory is not configured correctly.

I can see that "destination directory " has an empty value.

It's a production site so I can't risk wiping everything out as #2 says is possible with mailsystem-7.x-3.0-alpha1 or 7.x-3.x-dev.

This ends up being a problem for Drupal installs on AWS using S3 that also want to send html email with the Simple Email Service (SES) as the SMTP server. Using SES has the added benefit of email authentication with their easy implementation of SPF and DKIM records.

Would love to hear if this is going to be fixed or if there's an alternative method to get this working using Mime Mail, SMTP Mail, S3 and SES.

terrylb’s picture

Just to follow up on my previous post and help someone else, I was able to get Mime + SMTP working by setting $class_dir = 'private://mailsystem'; inside mailsystem.module. In addition, the checkbox for Send links only in the MIME Mail module needed to be enabled otherwise email wasn't sent and errors showed in the log: "phpmailerException: Message body empty in PHPMailer->Send() (line 577 of /var/app/current/sites/all/modules/contrib/smtp/smtp.phpmailer.inc)"

dobe’s picture

I wanted to chime in here. My guess is that @terrylb is running a single AWS instance. With there private directory not being controlled by S3.

Issue here is that what if you have your private directory on S3. Then drupal tries to autoload an external file... which I don't think is possible.

Second issue. IF you do have your private filesystem local to your install (not on s3) and if you have more then 1 EC2 instance... then when you save your new class file... Well only the instance that was being used when you save the file gets that new file. So it may be better to register you own class with the file that is generated.

dobe’s picture

Follow up herre:

I created a file that is basically what is generated by mailsystem
MyCustomMailSystem.mail.inc

<?php
class MyCustomMailSystem implements MailSystemInterface {
	protected $formatClass;
	protected $mailClass;
	public function __construct() {
		if (drupal_autoload_class('HTMLMailSystem')) {
			$this->formatClass = new HTMLMailSystem;
		}
		else {
			$this->formatClass = new DefaultMailSystem;
		}
		if (drupal_autoload_class('SmtpMailSystem')) {
			$this->mailClass = new SmtpMailSystem;
		}
		else {
			$this->mailClass = new DefaultMailSystem;
		}
	}
	public function format(array $message) {
		return $this->formatClass->format($message);
	}
	public function mail(array $message) {
		return $this->mailClass->mail($message);
	}
}

added this to my custom module directory.

Then added this to mycustom.info module file so it will get auto loaded.
files[] = MyCustomMailSystem.mail.inc

About to test if this works for me. But it should :D

DamienMcKenna’s picture

Status: Active » Needs review
Issue tags: -s3fs mailsystem s3 +s3fs, +s3
FileSize
2.01 KB

Does this work? I tried to combine a change someone made ages ago on a project I've taken over, with the latest codebase.