Hello,
I have setup Invoice Plan 2.0 A in my ubuntu 18.04 along side with invoice plane 1.5.9.
I have the email account used to email invoices the same on both versions. I can send invoices successfully from Invoice Plane 1.5.9, but nothing happen when i try to send invoices from version 2.0.
Anyhelp would be appreciated.
It is known already.
A work around would be to remove the fields that aren’t being used. For example, I didn’t need the CC but wanted to keep the BCC . Below, I removed both CC and BCC . Unless you remove these fields from the view files, you will still see the fields, you just won’t be able to use them.
Edit this file:
/app/Modules/MailQueue/Support/MailQueue.php
> <?php
>
> /**
> * InvoicePlane
> *
> * @package InvoicePlane
> * @author InvoicePlane Developers & Contributors
> * @copyright Copyright (C) 2014 - 2018 InvoicePlane
> * @license https://invoiceplane.com/license
> * @link https://invoiceplane.com
> *
> * Based on FusionInvoice by Jesse Terry (FusionInvoice, LLC)
> */
>
> namespace FI\Modules\MailQueue\Support;
>
> use FI\Support\PDF\PDFFactory;
> use Illuminate\Support\Facades\Mail;
>
> class MailQueue
> {
> protected $error;
>
> public function create($object, $input)
> {
> return $object->mailQueue()->create([
> 'from' => json_encode(['email' => $object->user->email, 'name' => $object->companyProfile->company]),
> 'to' => json_encode($input['to']),
> 'subject' => $input['subject'],
> 'body' => $input['body'],
> 'attach_pdf' => $input['attach_pdf'],
> ]);
> }
>
> public function send($id)
> {
> $mail = \FI\Modules\MailQueue\Models\MailQueue::find($id);
>
> if ($this->sendMail(
> $mail->from,
> $mail->to,
> $mail->subject,
> $mail->body,
> $this->getAttachmentPath($mail)
> )
> ) {
> $mail->sent = 1;
> $mail->save();
>
> return true;
> }
>
> return false;
> }
>
> private function sendMail($from, $to, $subject, $body, $attachmentPath = null)
> {
> try {
> $htmlTemplate = (view()->exists('email_templates.html')) ? 'email_templates.html' : 'templates.emails.html';
>
> Mail::send([$htmlTemplate, 'templates.emails.text'], ['body' => $body], function ($message) use ($from, $to, $subject, $attachmentPath) {
> $from = json_decode($from, true);
> $to = json_decode($to, true);
> $message->from($from['email'], $from['name']);
> $message->subject($subject);
>
> foreach ($to as $toRecipient) {
> $message->to(trim($toRecipient));
> }
>
> if (config('fi.mailReplyToAddress')) {
> $message->replyTo(config('fi.mailReplyToAddress'));
> }
>
> if ($attachmentPath) {
> $message->attach($attachmentPath);
> }
> });
>
> if ($attachmentPath and file_exists($attachmentPath)) {
> unlink($attachmentPath);
> }
>
> return true;
> } catch (\Exception $e) {
> $this->error = $e->getMessage();
>
> return false;
> }
> }
>
> private function getAttachmentPath($mail)
> {
> if ($mail->attach_pdf) {
> $object = $mail->mailable;
>
> $pdfPath = base_path('storage/' . $object->pdf_filename);
>
> $pdf = PDFFactory::create();
>
> $pdf->save($object->html, $pdfPath);
>
> return $pdfPath;
> }
>
> return null;
> }
>
> public function getError()
> {
> return $this->error;
> }
> }
Thanks alot for your input, i am also need to keep the bcc, so i removed all the lines related to the cc from my file, and seems to be working now. Thanks.
1 Like