From a2bf022e5295ac738850b6bb2235806742dbd62f Mon Sep 17 00:00:00 2001 From: Theo Weijmer Date: Sun, 25 Aug 2024 20:26:36 +0200 Subject: [PATCH] produktie mail naar postmark --- application/config/email.php | 1 - application/controllers/Login.php | 55 +++++++++++++----------- application/models/shared/Mail_model.php | 24 +++++------ 3 files changed, 41 insertions(+), 39 deletions(-) diff --git a/application/config/email.php b/application/config/email.php index 6207905..bf58f7a 100644 --- a/application/config/email.php +++ b/application/config/email.php @@ -19,7 +19,6 @@ $config['charset'] = 'iso-8859-1'; -$config['protocol'] = $_ENV['MAIL']['PROTOCOL']; $config['smtp_host'] = $_ENV['MAIL']['HOST']; $config['smtp_user'] = $_ENV['MAIL']['SMTP_USER']; $config['smtp_pass'] = $_ENV['MAIL']['SMTP_PASS']; diff --git a/application/controllers/Login.php b/application/controllers/Login.php index 1a92820..5989fef 100644 --- a/application/controllers/Login.php +++ b/application/controllers/Login.php @@ -218,33 +218,36 @@ class Login extends MY_Controller { $data = ['username' => $username, 'password' => $password, 'fullname' => $this->Users_model->get_fullname( $userid )]; $html = $this->load->view( 'emails/newpassword_mail', $data, TRUE ); - if( $_ENV['ENVIRONMENT'] == 'production') - { - //Deze code wordt alleen op produktie gebruikt en stuurt de mail - //naar Mailgun via een API (Codeigniter email library wordt niet gebruikt - $mg = Mailgun::create( $_ENV['MAIL']['APIKEY'] ); - $mg->messages()->send( $_ENV['MAIL']['DOMAIN'], [ - 'from' => 'info@monpas.nl', - 'to' => $email, - 'cc' => 'rfranke@framework-ed.nl', - 'subject' => 'Inloggegevens MonPas', - 'html' => $html, - 'inline' => [ - [ - 'filename' => 'monpasklein.png', - 'filePath' => FCPATH . 'css/images/monpasklein.png'] - ] - ] ); - }else{ - $this->load->library( 'email' ); - $this->email->from( 'noreply@framework.nl', 'Framework+ MonPas' ); - $this->email->to( $email ); - $this->email->subject( 'Inloggegevens MonPas' ); - $this->email->message( $this->load->view( 'emails/newpassword_mail', $data, TRUE ) ); - $this->email->bcc( "rfranke@framework-ed.nl" ); - $this->email->send(); - } + $this->Mail_model->sendTheEmail($email, 'Inloggegevens MonPas', $html, "rfranke@framework-ed.nl"); + +// if( $_ENV['ENVIRONMENT'] == 'production') +// { +// //Deze code wordt alleen op produktie gebruikt en stuurt de mail +// //naar Mailgun via een API (Codeigniter email library wordt niet gebruikt +// $mg = Mailgun::create( $_ENV['MAIL']['APIKEY'] ); +// $mg->messages()->send( $_ENV['MAIL']['DOMAIN'], [ +// 'from' => 'info@monpas.nl', +// 'to' => $email, +// 'cc' => 'rfranke@framework-ed.nl', +// 'subject' => 'Inloggegevens MonPas', +// 'html' => $html, +// 'inline' => [ +// [ +// 'filename' => 'monpasklein.png', +// 'filePath' => FCPATH . 'css/images/monpasklein.png'] +// ] +// ] ); +// }else{ +// $this->load->library( 'email' ); +// +// $this->email->from( 'noreply@framework.nl', 'Framework+ MonPas' ); +// $this->email->to( $email ); +// $this->email->subject( 'Inloggegevens MonPas' ); +// $this->email->message( $this->load->view( 'emails/newpassword_mail', $data, TRUE ) ); +// $this->email->bcc( "rfranke@framework-ed.nl" ); +// $this->email->send(); +// } $result['errortekst'] = 'Er is een e-mail gestuurd naar ' . $email . ' met uw nieuwe wachtwoord.'; $result['status'] = TRUE; diff --git a/application/models/shared/Mail_model.php b/application/models/shared/Mail_model.php index a5450b3..da15424 100644 --- a/application/models/shared/Mail_model.php +++ b/application/models/shared/Mail_model.php @@ -22,22 +22,22 @@ class Mail_model extends MY_Model{ if ( ! is_array( $to ) ) $to = (array) $to; foreach ( $to as $receiver ){ - - $mailParts = explode( '@', $receiver ); - if (! $mailParts || count($mailParts) < 2) return $result="Er gaat iets fout met e-mail adres ".$receiver; + $mailParts = explode( '@', $receiver ); + if (! $mailParts || count($mailParts) < 2) + return $result="Er gaat iets fout met e-mail adres ".$receiver; - // moet dit gebeuren? $this->setmail(); + $this->email->to( $receiver ); + $this->email->from( 'info@monpas.nl', 'Framework MonPas' ); + if ( $cc ) $this->email->bcc( $cc ); - $this->email->to( $receiver ); - $this->email->from( 'info@monpas.nl', 'Framework MonPas' ); - if ( $cc ) $this->email->bcc( $cc ); + $this->email->subject( $subject ); + $this->email->message( $html ); - $this->email->subject( $subject ); - $this->email->message( $html ); + $sendResult = $this->email->send(); - if ( ! $this->email->send() ){ - $result = $this->email->print_debugger(); - }; + if ( ! $sendResult ){ + $result = $this->email->print_debugger(); + }; } return $result;