Community Forums

Emailing a wishlist 1.5.2.1

Coding & concept discussion for OpenCart v1.x development

Emailing a wishlist 1.5.2.1

Postby danasgarcia » Fri Apr 20, 2012 1:09 am

Hello all, I have currently coded a few addin pages that allow a guest to view a customers wishlist if they choose to make it public. I was wondering if any of you know how to load the mail module and use it? I have been looking through stock controllers and haven't seen it called. I tried
Code: Select all
$this->mail->setTo("email@email.com");
and also loaded the other required arguements before I tried
Code: Select all
$this->mail->send();
. I'm assuming by my lack of success that this is the incorrect way to do it or I should have loaded it. Any help would be greatly appreciated.
danasgarcia
 
Posts: 2
Joined: Fri Apr 20, 2012 1:02 am

Re: Emailing a wishlist 1.5.2.1

Postby avvici -arvixe- » Fri Apr 20, 2012 4:19 am

Here is an example of setting up mail. This example can either use a template...or just a text string to be echoed on the email.
Code: Select all
 $template = new Template();
         $template->data['order_id'] = $order_id;
         $text = "YOUR TEXT OR VARIABLE";
         //LOCATION OF YOUR HTML TEMPLATE
         if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/mail/order.tpl')) {
            $html = $template->fetch($this->config->get('config_template') . '/template/mail/order.tpl');
         } else {
            $html = $template->fetch('default/template/mail/order.tpl');
         }
         $mail = new Mail();
         $mail->protocol = $this->config->get('config_mail_protocol');
         $mail->parameter = $this->config->get('config_mail_parameter');
         $mail->hostname = $this->config->get('config_smtp_host');
         $mail->username = $this->config->get('config_smtp_username');
         $mail->password = $this->config->get('config_smtp_password');
         $mail->port = $this->config->get('config_smtp_port');
         $mail->timeout = $this->config->get('config_smtp_timeout');         
         $mail->setTo($order_info['email']);
         $mail->setFrom($this->config->get('config_email'));
         $mail->setSender($order_info['store_name']);
         $mail->setSubject(html_entity_decode($subject, ENT_QUOTES, 'UTF-8'));
         //IF YOU ARE NOT USING A TEMPLATE MAKE SURE TO COMMENT OUT THE LINE BELOW
         $mail->setHtml($html);
         ////////////////////////
         $mail->setText(html_entity_decode($text, ENT_QUOTES, 'UTF-8'));
         $mail->send();


Again, you will need to make sure certain variables are filled such as recipient email, subject, and so on and so forth. This will work for you.
Image Image
User avatar
avvici -arvixe-
 
Posts: 4338
Joined: Tue Apr 05, 2011 4:09 am
Location: Charlotte, NC

Re: Emailing a wishlist 1.5.2.1

Postby danasgarcia » Sat Apr 21, 2012 1:46 pm

Thank you so much, I appreciate your help. I didn't even think to just initialize it as an object.
danasgarcia
 
Posts: 2
Joined: Fri Apr 20, 2012 1:02 am

Re: Emailing a wishlist 1.5.2.1

Postby avvici -arvixe- » Sat Apr 21, 2012 4:53 pm

Object Oriented Language O0
Image Image
User avatar
avvici -arvixe-
 
Posts: 4338
Joined: Tue Apr 05, 2011 4:09 am
Location: Charlotte, NC


Return to Concepts

Who is online

Users browsing this forum: No registered users and 13 guests

Hosted by Arvixe Web Hosting