Page 1 of 1

Names with e-mail addresses in Decorator?

Posted: Mon Mar 02, 2009 9:30 am
by HHahn
I have been messing around with PHP mail() and I can confirm most of the disadvantages reported. As a replacement, I found PHPMailer, which works relatively fine but has some drawbacks. E.g., CC: and BCC: are not properly processed.

As a further improvement, I am now evaluating SwiftMailer. This seems to work pretty reliably.

However, there is one aspect that I cannot get hold of. When I try Swift plugin "Decorator", I can indeed send multiple e-mails to multiple receivers. However, the replacements are specified by an associative array, the keys of which are the receivers' e-mail addresses. So far, so good. But I do not manage to add names to the receivers' e-mail addresses (like "John Doe <j.doe@somewhere.xy>", or "\"John Doe\" <j.doe@somewhere.xy>"). These produce an error message from the Decorator, which only accepts pure e-mail addresses or Swift_Address instances. But the latter cannot be used as keys for an associative array, as these keys are not allowed to be arrays or objects.

So the question is: How can I add names to the receivers' e-mail addresses when using the plugin Decorator?

Re: Names with e-mail addresses in Decorator?

Posted: Mon Mar 02, 2009 3:00 pm
by Chris Corbyn
HHahn wrote:I have been messing around with PHP mail() and I can confirm most of the disadvantages reported. As a replacement, I found PHPMailer, which works relatively fine but has some drawbacks. E.g., CC: and BCC: are not properly processed.

As a further improvement, I am now evaluating SwiftMailer. This seems to work pretty reliably.

However, there is one aspect that I cannot get hold of. When I try Swift plugin "Decorator", I can indeed send multiple e-mails to multiple receivers. However, the replacements are specified by an associative array, the keys of which are the receivers' e-mail addresses. So far, so good. But I do not manage to add names to the receivers' e-mail addresses (like "John Doe <j.doe@somewhere.xy>", or "\"John Doe\" <j.doe@somewhere.xy>"). These produce an error message from the Decorator, which only accepts pure e-mail addresses or Swift_Address instances. But the latter cannot be used as keys for an associative array, as these keys are not allowed to be arrays or objects.

So the question is: How can I add names to the receivers' e-mail addresses when using the plugin Decorator?
The keys in the decorator (email addresses) are not used for sending, they are only used for lookup of the correct replacements. You should not need to add names.

The names should be provided to the RecipientList object that you pass to batchSend() or send().