Skip to main content
removeu 677 caracteres do conteúdo
Fonte Link

Olá,

Pelo que notei, não está com problema, apenas com dúvida de como fazer!

Olhe os exemplos na documentação: PHPMailer/examples

Exemplo SMTP: sendmail.php

<?php
/**
 * This example shows sending a message using a local sendmail binary.
 */

//Import the PHPMailer class into the global namespace
use PHPMailer\PHPMailer\PHPMailer;

require '../vendor/autoload.php';

//CreatePassing a`true` newenables PHPMailer instanceexceptions
$mail = new PHPMailer;
// Set PHPMailer to use();
 the sendmail transport
$mail->isSendmail>isSMTP();
//Set who the message is$mail->Host to= be'smtp.example.com';
$mail->SMTPAuth sent= fromtrue;
$mail->setFrom('[email protected]',>Port 'First= Last');25;
//Set an$mail->Username alternative= reply'[email protected]';
$mail-to>Password address= 'yourpassword';
$mail->addReplyTo>setFrom('replyto@example'list@example.com', 'First'List Last'manager');
//Set who the message is to be sent to
$mail->addAddress>addReplyTo('whoto@example'list@example.com', 'John'List Doe'manager');
//Set the subject line
$mail->Subject = 'PHPMailer sendmail test';
//Read an HTML message body from an external file, convertSimple referenceddatabase imagesmailing tolist embedded,test';
//convert HTML into a basic plain-text alternative body
$mail->msgHTML(file_get_contents('contents.html'), __DIR__$body);
//Replace the plain text body with one created manually
$mail->AltBody = 'This is'To aview plain-textthe message, body';
//Attachplease use an imageHTML filecompatible email viewer!';

$mail->addAttachment>addAddress('images/phpmailer_mini.png');

//send the message$email, check for errors$name);
if (!$mail->send()) {
    echo 'Mailer Error: '. $mail->ErrorInfo;
}; else// {
TRATE AQUI PARA VER echoSE 'MessageENVIOU sent!';
}MESMO

Olá,

Pelo que notei, não está com problema, apenas com dúvida de como fazer!

Olhe os exemplos na documentação: PHPMailer/examples

Exemplo: sendmail.php

<?php
/**
 * This example shows sending a message using a local sendmail binary.
 */

//Import the PHPMailer class into the global namespace
use PHPMailer\PHPMailer\PHPMailer;

require '../vendor/autoload.php';

//Create a new PHPMailer instance
$mail = new PHPMailer;
// Set PHPMailer to use the sendmail transport
$mail->isSendmail();
//Set who the message is to be sent from
$mail->setFrom('[email protected]', 'First Last');
//Set an alternative reply-to address
$mail->addReplyTo('replyto@example.com', 'First Last');
//Set who the message is to be sent to
$mail->addAddress('whoto@example.com', 'John Doe');
//Set the subject line
$mail->Subject = 'PHPMailer sendmail test';
//Read an HTML message body from an external file, convert referenced images to embedded,
//convert HTML into a basic plain-text alternative body
$mail->msgHTML(file_get_contents('contents.html'), __DIR__);
//Replace the plain text body with one created manually
$mail->AltBody = 'This is a plain-text message body';
//Attach an image file
$mail->addAttachment('images/phpmailer_mini.png');

//send the message, check for errors
if (!$mail->send()) {
    echo 'Mailer Error: '. $mail->ErrorInfo;
} else {
    echo 'Message sent!';
}

Olá,

Pelo que notei, não está com problema, apenas com dúvida de como fazer!

Olhe os exemplos na documentação: PHPMailer/examples

Exemplo SMTP:

<?php
//Passing `true` enables PHPMailer exceptions
$mail = new PHPMailer();
   
$mail->isSMTP();
$mail->Host = 'smtp.example.com';
$mail->SMTPAuth = true;
$mail->Port = 25;
$mail->Username = '[email protected]';
$mail->Password = 'yourpassword';
$mail->setFrom('list@example.com', 'List manager');
$mail->addReplyTo('list@example.com', 'List manager');

$mail->Subject = 'PHPMailer Simple database mailing list test';

$mail->msgHTML($body);
$mail->AltBody = 'To view the message, please use an HTML compatible email viewer!';

$mail->addAddress($email, $name);
$mail->send(); // TRATE AQUI PARA VER SE ENVIOU MESMO
Fonte Link

Olá,

Pelo que notei, não está com problema, apenas com dúvida de como fazer!

Olhe os exemplos na documentação: PHPMailer/examples

Exemplo: sendmail.php

<?php
/**
 * This example shows sending a message using a local sendmail binary.
 */

//Import the PHPMailer class into the global namespace
use PHPMailer\PHPMailer\PHPMailer;

require '../vendor/autoload.php';

//Create a new PHPMailer instance
$mail = new PHPMailer;
// Set PHPMailer to use the sendmail transport
$mail->isSendmail();
//Set who the message is to be sent from
$mail->setFrom('[email protected]', 'First Last');
//Set an alternative reply-to address
$mail->addReplyTo('[email protected]', 'First Last');
//Set who the message is to be sent to
$mail->addAddress('[email protected]', 'John Doe');
//Set the subject line
$mail->Subject = 'PHPMailer sendmail test';
//Read an HTML message body from an external file, convert referenced images to embedded,
//convert HTML into a basic plain-text alternative body
$mail->msgHTML(file_get_contents('contents.html'), __DIR__);
//Replace the plain text body with one created manually
$mail->AltBody = 'This is a plain-text message body';
//Attach an image file
$mail->addAttachment('images/phpmailer_mini.png');

//send the message, check for errors
if (!$mail->send()) {
    echo 'Mailer Error: '. $mail->ErrorInfo;
} else {
    echo 'Message sent!';
}