Jump to content
Fórum Script Brasil
  • 0

Enviar Email Via Socket com Anexo


Gneccao
 Share

Question

Boa noite,

Estou tentando enviar email via Socket, ate ai tudo bem o email chega e tudo certo, o problema aparece quando tento enviar um anexo, tentei varias formas. mudei os Content do email e mesmo assim o email aparece sem anexo e com as informacoes do anexo no body.

Gostaria de uma luz ou uma ajuda pra enviar body + anexo.

Funcao Enviar Anexo

private function getAdd()
    {
        for($x = 0; $x < $this->CountAnexo(); $x++)
        {
            $info = pathinfo($this->_anexo[$x]);
            $type = $this->ReturnType($info['extension']);
                                                 
            $value = "--" . $this->_boundary . "\r\n" . "Content-Type: " . $type . "; name=\"". $info['filename'] . "\"" . "\r\n" .
            "Content-Transfer-Encoding: base64" . "\r\n" . "Content-Disposition: attachment; filename=\"" . $info['filename'] . "\"" . "\r\n" .
            "\r\n" . base64_encode(file_get_contents($this->Anexos[$x])) . "\r\n\r\n" . "--" . $this->_boundary  . "--";
            
            if($this->sendPack($value,'',0xFF) === false)
            {
                return false;
            }
            
        } 
        return true;

    }
$pack = 'Subject: ' . $this->_emailSubject . "\r\n" .  'To: <' . implode('>, <', $this->_emailTo) . '>' . "\r\n" . "Date: " . date("d M y H:i:s") . "\r\n" . "MIME-Version: 1.0" . 
            "Content-Type: multipart/mixed; boundary=" . $this->_boundary . '--' . $this->_boundary . "\r\n" . "Content-Type: text/html; charset=UTF-8";                                              
            
            if($this->sendPack($pack,'',0xFF) === false)
            {
                return false;
            }    
            
            if($this->sendPack($this->_emailBody,"\r\n",0xFF) === false)
            {
                return false;
            }    

            if($this->getAdd() === false)
            {
                return false;
            }

o Arquivo vem assim

Testando Email

--ab97b2a151282b7a887f87b2cea99f55

Content-Type: application/rar; name="oi"

Content-Transfer-Encoding: base64

Content-Disposition: attachment; filename="oi"

oi.rar

--ab97b2a151282b7a887f87b2cea99f55

obrigado

Link to comment
Share on other sites

2 answers to this question

Recommended Posts

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share



  • Forum Statistics

    • Total Topics
      150.8k
    • Total Posts
      648.8k
×
×
  • Create New...