mirror of
				https://github.com/invoiceninja/invoiceninja.git
				synced 2025-11-03 22:47:32 -05:00 
			
		
		
		
	Merge pull request #4874 from turbo124/v5-develop
Fixes for gmail attachments
This commit is contained in:
		
						commit
						914c27062f
					
				@ -61,41 +61,21 @@ class GmailTransport extends Transport
 | 
			
		||||
        $this->gmail->cc($message->getCc());
 | 
			
		||||
        $this->gmail->bcc($message->getBcc());
 | 
			
		||||
 | 
			
		||||
        foreach ($message->getChildren() as $child) {
 | 
			
		||||
        foreach ($message->getChildren() as $child) 
 | 
			
		||||
        {
 | 
			
		||||
 | 
			
		||||
            nlog("trying to attach");
 | 
			
		||||
            nlog($child->getContentType());
 | 
			
		||||
 | 
			
		||||
            if($child->getContentType() != 'text/plain')
 | 
			
		||||
            {
 | 
			
		||||
 | 
			
		||||
            if($child->getContentType() != 'text/plain'){
 | 
			
		||||
 | 
			
		||||
                nlog($child->getHeaders());
 | 
			
		||||
                
 | 
			
		||||
                $this->gmail->attach(TempFile::filePath($child));
 | 
			
		||||
            $this->gmail->attach(TempFile::filePath($child->getBody(), $child->getHeaders()->get('Content-Type')->getParameter('name') ));
 | 
			
		||||
            
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        foreach ($message->getChildren() as $child) {
 | 
			
		||||
            nlog("trying to attach");
 | 
			
		||||
        } 
 | 
			
		||||
 | 
			
		||||
            if($child->getContentType() != 'text/plain'){
 | 
			
		||||
 | 
			
		||||
// $attachment = (new Swift_Attachment())
 | 
			
		||||
//   ->setFilename($child->getHeaders()->get('Content-Type')->getParameter('name'))
 | 
			
		||||
//   ->setContentType($child->getContentType())
 | 
			
		||||
//   ->setBody($child->getBody());
 | 
			
		||||
 | 
			
		||||
            $this->gmail->attach(new Swift_Attachment($child));
 | 
			
		||||
            
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        } //todo this should 'just work'
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        } //todo this should 'just work'
 | 
			
		||||
 | 
			
		||||
        $this->gmail->send();
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -22,10 +22,10 @@ class TempFile
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /* Downloads a file to temp storage and returns the path - used for mailers */
 | 
			
		||||
    public static function filePath($data) :string
 | 
			
		||||
    public static function filePath($data, $filename) :string
 | 
			
		||||
    {
 | 
			
		||||
 | 
			
		||||
        $file_path = sys_get_temp_dir().'/'.sha1(microtime());
 | 
			
		||||
        $file_path = sys_get_temp_dir().'/'.sha1(microtime() . '/' . $filename);
 | 
			
		||||
 | 
			
		||||
        file_put_contents($file_path, $data);
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user