It seems like a very basic question so sorry if I have missed something obvious...
I'm trying to send a 'from' name and e-mail in a variable to Swift_Address but it doesn't seem to like it.
this works:
if ($swift->send($message, new Swift_Address($email), new Swift_Address("info@XXX.com", "XXX name"))) echo "Sent";
else echo "Failed";
this doesn't work
$from = '"info@XXX.com", "XXX name"';
if ($swift->send($message, new Swift_Address($email), new Swift_Address($from))) echo "Sent";
else echo "Failed";
how to pass variable to Swift_Address?
Moderators: Chris Corbyn, General Moderators
Re: how to pass variable to Swift_Address?
That's because Swift Address wants 2 parameters, and you are only giving it one.
Same as
Code: Select all
$from = array('email@site.com','name');
new Swift_Address($from[0],$from[1]);Code: Select all
$from1 = 'email@site.com';
$from2 = 'name';
new Swift_Address($from1,$from2);Re: how to pass variable to Swift_Address?
Smashing - thanks!!