Welcome to the Treehouse Community
The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.
Amber Hoddinott6,494 Points
Can some please explain to me how to fill in the setTO() method?
I have built a site on my own apple mac computer and i am using mamp as the server at the moment, i have used all the php in this course... everything seems to be working i dont think there is anything wrong with my code. (when i send the email it redirects back to my home page, which makes me think that the email is sending it just not sending properly)
I am sure however that i am either not writing the correct thing in my setTo() method or/and i havent got something installed on my computer that makes it possible for the email to send. (i have read in another question on here i need "sendmailer") however after looking at the site and downloading it, i have to say i have no idea what to do next? please help me if that is the case.
this is my code......
$transport = Swift_SendmailTransport::newInstance('/usr/sbin/sendmail -bs');
$mailer = \Swift_Mailer::newInstance($transport); $message = \Swift_Message::newInstance(); $message -> setSubject('Email from our website'); $message -> setFrom(array( $cleanEmail => $cleanName )); $message -> setTo(array('firstname.lastname@example.org' => 'Ambermaria')); <--------this is where i need help i think???? $message -> setBody($cleanMsg);
thank you in advance ... any help very much appreciated!!!! :D
I would go with PHP Mailer (found on GitHub). That's a very simple to use PHP mailer with very little configuration needed and it works with LocalHost environments, as well. There's a lot of support found on the internet for it, as well. I hope this helps!