Laravel电子邮件无法与Invitation.ics附件一起使用?

时间:2019-06-18 05:35:01

标签: laravel email smtp

我尝试使用MAIL HOST'smtp.office365.com'发送带有日历邀请的电子邮件,它可以正常工作,但是当我将MAIL_HOST更改为'nl1-ls4.a2hosting.com'时,它不起作用。

我无法使用smtp.office365.com smtp,因为我的托管服务不支持第三方电子邮件,因此我只是将smtp更改为“ nl1-ls4.a2hosting.com”,但是使用Invitation.ics附件无法正常工作,无需附件即可工作

#SMTP CONFIG
MAIL_DRIVER=smtp
MAIL_HOST=nl1-ls4.a2hosting.com
MAIL_PORT=587
MAIL_USERNAME=***
MAIL_PASSWORD=***
MAIL_ENCRYPTION=tls

#generate calendar and send email
     $ics_output = $this->createCalendar($con_date, $appointment->appointment_time, $to_email, $attendee_name);
                $filename = "invite.ics";
                header("text/calendar");
                file_put_contents($filename, $ics_output);

                $objDemo = new \stdClass();

                $objDemo->date = $appointment->appointment_date;
                $objDemo->time = $appointment->appointment_converted_time;
                $objDemo->time_zone = '';
                $objDemo->receiver_email = $appointment->primary_email;
                $objDemo->first_name = $appointment->first_name;
                $objDemo->last_name = $appointment->last_name;
                $objDemo->mobile_phone = $appointment->mobile_phone;
                $objDemo->message = $appointment->message;
                $objDemo->filename = $filename;
                $objDemo->title = $appointment->first_name.' - Appointment has been confirmed!';

                $objDemo->subject = 'Confirmed: 15 Minutes Call Regarding '. $appointment->first_name .' Enquiry @ '.$appointment->appointment_date.', '.$appointment->appointment_converted_time;

                try{
                    Mail::to($to_email)->send(new SendMailable($objDemo));
                }catch(\Exception $e){
                    echo "<pre>";
                    print_r($e->getMessage());
                    print_r($e->getCode());
                    echo "</pre>";
                    die();
                }
    #send mailable
        public function build()
        {
           if($this->demo->filename){
                return $this
                ->view('emails.appointment_confirmation')
                ->subject($this->demo->subject)
                ->attach($this->demo->filename, array('mime' => "text/calendar"));
            }else{
                return $this
                ->view('emails.appointment_confirmation')
                ->subject($this->demo->subject);
            }
        }

    No error message..

0 个答案:

没有答案