Bugfix and language updates

Fixed links and language translations in installert.
Fixed outgoing mail issue.
This commit is contained in:
Manish Verma
2018-08-13 18:39:36 +05:30
parent 3a52d6f24f
commit 2f6ce43fe1
7 changed files with 101 additions and 57 deletions

View File

@@ -16,6 +16,15 @@ use Mail;
class PhpMailController extends Controller
{
/**
*@var variable to instantiate common mailer class
*/
public function __construct()
{
$this->commonMailer = new CommonMailer;
}
public function fetch_smtp_details($id)
{
$emails = Emails::where('id', '=', $id)->first();
@@ -161,45 +170,42 @@ class PhpMailController extends Controller
$content = $messagebody;
}
}
$send = $this->laravelMail($recipants, $recipantname, $subject, $content, $cc, $attachment);
$send = $this->laravelMail($recipants, $recipantname, $subject, $content, $from_address, $cc, $attachment);
return $send;
}
public function setMailConfig($from_address)
public function setMailConfig($mail)
{
$username = $from_address->email_address;
$fromname = $from_address->email_name;
$password = $from_address->password;
$smtpsecure = $from_address->sending_encryption;
$host = $from_address->sending_host;
$port = $from_address->sending_port;
$protocol = $from_address->sending_protocol;
$this->setServices($from_address->id, $protocol);
if ($protocol == 'mail') {
$username = '';
$fromname = '';
$host = '';
$smtpsecure = '';
$port = '';
}
$configs = [
'username' => $username,
'from' => ['address' => $username, 'name' => $fromname],
'password' => $password,
'encryption' => $smtpsecure,
'host' => $host,
'port' => $port,
'driver' => $protocol,
];
foreach ($configs as $key => $config) {
if (is_array($config)) {
foreach ($config as $from) {
\Config::set('mail.'.$key, $config);
switch ($mail->sending_protocol) {
case 'smtp':
$config = ['host' => $mail->sending_host,
'port' => $mail->sending_port,
'security' => $mail->sending_encryption,
'username' => $mail->email_address,
'password' => $mail->password,
];
if (!$this->commonMailer->setSmtpDriver($config)) {
\Log::info('Invaid configuration :- '.$config);
return 'invalid mail configuration';
}
} else {
\Config::set('mail.'.$key, $config);
}
break;
case 'send_mail':
$config = [
'host' => \Config::get('mail.host'),
'port' => \Config::get('mail.port'),
'security' => \Config::get('mail.encryption'),
'username' => \Config::get('mail.username'),
'password' => \Config::get('mail.password'),
];
$this->commonMailer->setSmtpDriver($config);
break;
case 'mailgun':
$this->commonMailer->setMailGunDriver(null);
break;
default:
return 'Mail driver not supported';
}
}
@@ -223,14 +229,14 @@ class PhpMailController extends Controller
return $value;
}
public function laravelMail($to, $toname, $subject, $data, $cc, $attach)
public function laravelMail($to, $toname, $subject, $data, $from_address, $cc, $attach)
{
//dd($to, $toname, $subject, $data, $cc, $attach);
//dd(\Config::get('mail'));
//dd($attach);
$mail = Mail::send('emails.mail', ['data' => $data], function ($m) use ($to, $subject, $toname, $cc, $attach) {
$mail = Mail::send('emails.mail', ['data' => $data], function ($m) use ($to, $subject, $toname, $cc, $attach, $from_address) {
$m->to($to, $toname)->subject($subject);
$m->from($from_address->email_address, $from_address->email_name);
if ($cc != null) {
foreach ($cc as $collaborator) {
//mail to collaborators