Want to modify 'to' line in message header

Swift Mailer is a fantastic library for sending email with php. Discuss this library or ask any questions about it here.

Moderators: Chris Corbyn, General Moderators

Post Reply
Paedda
Forum Newbie
Posts: 2
Joined: Tue Oct 09, 2007 8:21 am

Want to modify 'to' line in message header

Post by Paedda »

Hi there,

I am using the recipients object to handle multiple addresses.
That works fine but occasionally we use internal group email addresses.
These addresses are not actual email addresses therefore the group addresses
are not in the recipient list. But I need to provide them in the to line in the
header. Is there a way to do that?
I saw in other posts and in the manual that Swift creates the header on the fly while sending
from the recipient list so $message->setTo('foo@bar.com') does not help in this case.

Here is an example:

Code: Select all

// new message                
$message= new Swift_Message($subject);

// entered recipient addresses
// first one is group address		
$entered_address = array('group@address.com', 'foo@bar.com');

// new recipient list
// add only the actual valid email address	
// plus group member as Bcc's	
$recipients = new Swift_RecipientList();
$recipients->addTo('foo@bar.com');
$recipients->addBcc('groupMember_1@bar.com');
$recipients->addBcc('groupMember_2@bar.com');

// but need group address in header so that recipents sees that group address has entered
$message->setTo(array('group@address.com', 'foo@bar.com'));
		
App['SwiftMailer']->send($message, $recipients, "me@mydomain.com");

Thanks for your help!

Peter
Paedda
Forum Newbie
Posts: 2
Joined: Tue Oct 09, 2007 8:21 am

Post by Paedda »

Solved the proplem.
I was using NativeMail for testing and NativeMail rewrites the TO line in the header.
Changed it to SMTP and it works great!!!
Post Reply