PHP code example of nfephp-org / sped-mail

1. Go to this page and download the library: Download nfephp-org/sped-mail library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

nfephp-org / sped-mail example snippets


$resp = Mail::sendMail($config, $xml, $pdf, $addresses, $template, $pfx, $password, $mailer);


$config = new stdClass();
$config->smtpdebug = 0; //0-no 1-client 2-server 3-connection 4-lowlevel
$config->host = 'smtp.example.com.br';
$config->port = 587; //25 ou 465 ou 587
$config->smtpauth = true;
$config->user = '[email protected]';
$config->password = 'senha';
$config->secure = 'tls';
$config->authtype = ''; //'', CRAM-MD5, PLAIN, LOGIN, XOAUTH2
$config->from = '[email protected]';
$config->fantasy = 'Fulanoda Silva';
$config->replyTo = '[email protected]';
$config->replyName = 'Ciclano Moreira';
$config->smtpoptions = null; /*[
    'ssl' => [
        'verify_peer' => true,
        'verify_depth' => 3,
        'allow_self_signed' => true,
        'peer_name' => 'smtp.example.com',
        'cafile' => '/etc/ssl/ca_cert.pem',
    ]
];*/
$config->timeout = 130;



$xml = '../nfe.xml';

$xml = file_get_contents('../nfe.xml');

$pdf = '../nfe.pdf';

$pdf = file_get_contents('../nfe.pdf');

$addresses = ['[email protected]'];

$template = '<p>Meu HTML {emitente} .... ';

$pfx = file_get_contents('path ao certificado pfx');

$password = 'senha';

$mailer = new PHPMailer();