Page 1 of 1

how to setup dynamic email string for setTo

Posted: Wed Aug 04, 2010 10:28 am
by eggnogg
basically that what i wanna do but i can't seem to do it nor have i found anyone that tried it before.
basically im receiving a string with emails as so

john@gmail.com, maria@gmail, etc@gmail.com

and i want to use those emails and place them in the setTo field but i can't

ive tried creating a string with each email delimited with ', like

'john@gmail.com', 'maria@gmail', 'etc@gmail.com'

placing it in a variable and setting that variable in the setTo field but that fails.

so, how would i go about and doing it?

Re: how to setup dynamic email string for setTo

Posted: Wed Aug 04, 2010 2:30 pm
by Christopher
I assume you are using the mail() function? It should work with just a comma between email addresses.

Have you read this page carefully:

http://www.php.net/manual/en/function.mail.php

It gives many good examples.

Re: how to setup dynamic email string for setTo

Posted: Wed Aug 04, 2010 4:01 pm
by eggnogg
a little newb here, for that matter
...
no, i am using smpt...

and the following config:

Code: Select all

$transport = Swift_SmtpTransport::newInstance($setting_smtp_email['smtp_host'], $setting_smtp_email['smtp_port'],'ssl')
		  ->setUsername($setting_smtp_email['smtp_user'])
		  ->setPassword($setting_smtp_email['smtp_pass'])
		;
$mailMessage = Swift_Message::newInstance()
		  ->setSubject($subject)
		  ->setFrom(array($setting['setting_email_fromemail'] => $setting['setting_email_fromname']))
		  ->setSender(array($setting['setting_email_fromemail']))
		  ->setTo(array($recipient_email)) /* it's this guy that i haven't figured out how to use when setting more than one emails */
		  ->setBody($message, 'text/html')
		  ->addPart($textPlain_message, 'text/plain')
		;
                $result = $mailer->batchSend($mailMessage);

Re: how to setup dynamic email string for setTo

Posted: Wed Aug 04, 2010 8:37 pm
by eggnogg
resolved:
set up an array variable instead of a string.

Code: Select all

$var = array('a','b')
->setTo($var)
regards