Opencart send email in custom Script

I have a script in my opencart, made by myself, and want to make it send an email, but I think that when I try to get email parameters they return null.

Here is my code:

    $email_to = "somewhere@example.com";
    $config = new Config();
    $mail = new Mail();


    $mail->protocol = $config->get('config_mail_protocol');
    $mail->parameter = $config->get('config_mail_parameter');
    $mail->hostname = $config->get('config_smtp_host');
    $mail->username = $config->get('config_smtp_username');
    $mail->password = $config->get('config_smtp_password');
    $mail->port = $config->get('config_smtp_port');
    $mail->timeout = $config->get('config_smtp_timeout');            
    $mail->setTo($email_to);
    $mail->setFrom("nuno@[mydomain].com");
    $mail->setSender("nuno@[mydomain].com");
    $mail->setSubject("test send mail");
    $mail->setText("test message body text");
    $mail->send();

When I try calling: echo $config->get('config_mail_protocol'); it returns null.

Answers


Do not create new instances of Config but just simply call

$email_to = "somewhere@example.com";
$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($email_to);
$mail->setFrom("somewhere@example.com");
$mail->setSender("somewhere@example.com");
$mail->setSubject("test send mail");
$mail->setText("test message body text");

$mail->send();

Need Your Help

Why is the JDK NIO using so many anon_inode file descriptors?

java linux-kernel nio inode netty

I'm using Sun's JDK 1.6.0_26 and NIO (with Netty) and in lsof I see hundreds of file descriptors that are anon_inode:

In iOS, how do I get keyboard information to prevent keyboard overlay of text fields?

ios objective-c keyboard notifications uitextfielddelegate

I am setting up a NOTIFICATION to get KEYBOARD information to adjust the view so that the selected text field is not covered by the KEYBOARD.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.