$mailer = JFactory::getMailer();
$mailer->addAttachment([
$filename => $filepath,
]);
or send email with array of attachments via JFactory::getMailer()->sendMail()
Email should have attachment named $filename
Email has attachment named $filepath
It's also logical to use array with path=>name
pairs but not name=>path
because file name can be same for different attachments while sending same file is ridiculous.
Labels |
Added:
?
|
Bad, it limits sending multiple attachments via JFactory::getMailer()->sendMail() shortcut method :(
Personal rant, but I honestly dislike half the design of JMail
. It break the interface from the class it is inheriting from (PHPMailer
) by changing method signatures and what they will and won't accept. If we were decorating the mailer it'd be another story, but as a class extension, we've made some bad design decisions in the past. So I'd actually rather get rid of the array behaviors to be in line with the parent API or refactor JMail
to be a decorator around a PHPMailer
object.
Category | ⇒ | com_mailto |
Category | com_mailto | ⇒ | com_mailto Feature Request |
Priority | Medium | ⇒ | Low |
Status | New | ⇒ | Discussion |
Labels |
Added:
J3 Issue
|
Status | Discussion | ⇒ | Closed |
Closed_Date | 0000-00-00 00:00:00 | ⇒ | 2018-08-19 10:46:35 |
Closed_By | ⇒ | wilsonge |
I agree it's not the most optimal design but it is there now and would be a b/c break to modify. I've added a commit to improve the documentation around this so it should be clearer what the intention is. Closing.
It doesn't work as an associative array. You have to pass the file path as the first argument and the name as the second, these can either be a single string or an array (and if an array they must both contain the same number of elements).
So...
Or