Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    Regular Coder
    Join Date
    Jun 2009
    Posts
    141
    Thanks
    3
    Thanked 20 Times in 20 Posts

    getting a $value into array

    I am attempting to email to multiple recipients. I am using swiftmailer and following their guidelines. When I try to get the admins to email to it is erroring

    Fatal error: Uncaught exception 'Swift_RfcComplianceException' with message 'Address in mailbox given
    The outputted format from my db is
    PHP Code:
    $admins "'email_1@email.com', 'email_2@email.com'"
    The code from swiftmailer required for multiple is

    PHP Code:
    $message->setTo(array('some@address.tld''other@address.tld')); 
    I have attempted everything I can think of to output in the same format as this, ie.
    PHP Code:
    $message->setTo(array($admins)); 
    This appears to echo them in the right format for the mailer however I still get the exception. If I manually right the addresses into the code as oppose to using a variable from the DB query it works. So it doesnt like echoing in the value string.. Any help please!?

  • #2
    Regular Coder
    Join Date
    Mar 2010
    Posts
    199
    Thanks
    78
    Thanked 5 Times in 5 Posts
    Let me get this straight you store multiple admin emails in one database field and you separate them by comma in your database?
    I don't know why you would store them like that but if you lose the single quotes around the emails and do something like this:
    PHP Code:
    $admins "email_1@email.com, email_2@email.com";  

    $admin_ary explode(','$admins);
    $message->setTo($admin_ary); 
    Then it should work.

    But I would still recommend you two store the emails in separate rows.
    That way you could do a while loop to make your email array.
    Last edited by conware; 11-04-2012 at 01:04 AM.

  • #3
    Regular Coder
    Join Date
    Jun 2009
    Posts
    141
    Thanks
    3
    Thanked 20 Times in 20 Posts
    Thanks, that did the trick. The reason that I have data stored int his way is that it is a configuration table for the group. Most will have only 1 email but occasionally there may be a requirement for 2-5 people to receive the email. Cheers


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •