Post by El - Key » Sat Oct 20, 2012 3:27 pm

Hi,
I have an issue with the mail function of opencart. In the contact form, for each request, I'm trying to send 3 differents email :
  • The message to the owner
  • A customer service email to the customer
  • And a third message to an address that I created in the setting for custom purpose
Here is my code :

Code: Select all

$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($this->config->get('config_email'));
	  		$mail->setFrom($this->request->post['email']);
	  		$mail->setSender($this->request->post['name']);
	  		$mail->setSubject(html_entity_decode(sprintf($this->language->get('email_subject'), $this->config->get('config_name') ), ENT_QUOTES, 'UTF-8'));
	  		$mail->setText(strip_tags(html_entity_decode($this->request->post['enquiry'], ENT_QUOTES, 'UTF-8')));
      		$mail->send();

      		// Send a confirmation email to the user
      		$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($this->request->post['email']);
	  		$mail->setFrom($this->config->get('config_email_display'));
	  		$mail->setSender($this->request->post['name']);
	  		$mail->setSubject(html_entity_decode(sprintf($this->language->get('email_subject'), $this->config->get('config_name') ), ENT_QUOTES, 'UTF-8'));
	  		$name = $this->config->get('config_name');
      		//$mail->setHtml( sprintf( $this->language->get('email_html_client'), $name, $name ));
      		$mail->setText(strip_tags(html_entity_decode($this->request->post['enquiry'], ENT_QUOTES, 'UTF-8')));
      		$mail->send();


      		// Send a copy of this email to the public email address only if different than system email
      		if( $this->config->get('config_email') != $this->config->get('config_email_display') ){
      			$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($this->config->get('config_email_display'));
		  		$mail->setFrom($this->request->post['email']);
		  		$mail->setSender($this->request->post['name']);
		  		$mail->setSubject(html_entity_decode(sprintf($this->language->get('email_subject'), $this->config->get('config_name') ), ENT_QUOTES, 'UTF-8'));
		  		$mail->setText(strip_tags(html_entity_decode($this->request->post['enquiry'], ENT_QUOTES, 'UTF-8')));
	      		$mail->send();
      		}
So the system send an email to owner's email address and THAT'S ALL. Did I do something wrong?

Thanks for your help

Newbie

Posts

Joined
Tue Feb 28, 2012 1:44 pm
Who is online

Users browsing this forum: No registered users and 3 guests