1659609060
PHPMailer é uma biblioteca PHP que possui uma função embutida para enviar e-mails com segurança e facilidade usando PHP do servidor.
Mail é uma funcionalidade útil no site.
Ele é usado para verificação do usuário, senha esquecida, envio de informações, etc.
Neste tutorial, mostro como enviar e-mails usando o servidor SMTP com PHPmailer em PHP.
composer require phpmailer/phpmailer
autoload.php
arquivo no vendor
diretório.Set Up Mail Client
.NOTA – Pode diferir de acordo com o servidor.
Importe PHPMailer
, Exception
classifique e inclua 'vendor/autoload.php'
.
<?php
use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\Exception;
// Load Composer's autoloader
require 'vendor/autoload.php';
Crie um objeto de PHPMailer
.
// Instantiation and passing `true` enables exceptions
$mail = new PHPMailer(true);
Atribua 0 a $mail->SMTPDebug
para desabilitar a depuração. Para habilitar o passe 2.
$mail->SMTPDebug = 0; // 0 - Disable Debugging, 2 - Responses received from the server
Especifique o host do servidor em $mail->Host
, nome de usuário em $mail->Username
e senha em $mail->Password
. Atribuir e para . 'tls'
_$mail->SMTPSecure587$mail->Port
NOTA – Todo este valor é obtido do passo anterior.
$mail->Host = 'mail.makitweb.com'; // Specify main and backup SMTP servers
$mail->SMTPAuth = true; // Enable SMTP authentication
$mail->Username = 'test@makitweb.com'; // SMTP username
$mail->Password = 'password'; // SMTP password
$mail->SMTPSecure = 'tls';//PHPMailer::ENCRYPTION_STARTTLS; Enable TLS encryption, `PHPMailer::ENCRYPTION_SMTPS` also accepted
$mail->Port = 587; // TCP port to connect to
Especifique o email-id e o nome do remetente e o email-id e o nome do $mail->setFrom()
destinatário em $mail->addAddress()
.
$mail->setFrom('test@makitweb.com', 'Yogesh singh');
$mail->addAddress('Recipient email-id', 'Recipient name'); // Add a recipient
Especifique o assunto do correio e o corpo em $mail->Subject
, $mail->Body
e $mail->AltBody
.
$mail->isHTML(true); // Set email format to HTML
$mail->Subject = 'Send email using SMTP with PHPmailer';
$mail->Body = 'A test email from <a href="https://makitweb.com">maktiweb.com</a>';
$mail->AltBody = 'A test email from makitweb.com'; // Plain text for non-HTML mail clients
Anexar arquivo usando o $mail->addAttachment()
método. Você pode especificar o nome do arquivo usando o 2º parâmetro.
$mail->addAttachment('upload/file.pdf');
$mail->addAttachment('upload/image.png', 'image 1'); // Optional name
Ligue $mail->send()
para enviar uma solicitação.
Código concluído
<?php
// Import PHPMailer classes into the global namespace
// These must be at the top of your script, not inside a function
use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\Exception;
// Load Composer's autoloader
require 'vendor/autoload.php';
// Instantiation and passing `true` enables exceptions
$mail = new PHPMailer(true);
try {
//Server settings
$mail->SMTPDebug = 0; // 0 - Disable Debugging, 2 - Responses received from the server
$mail->isSMTP(); // Set mailer to use SMTP
$mail->Host = 'mail.makitweb.com'; // Specify main and backup SMTP servers
$mail->SMTPAuth = true; // Enable SMTP authentication
$mail->Username = 'test@makitweb.com'; // SMTP username
$mail->Password = 'password'; // SMTP password
$mail->SMTPSecure = 'tls';//PHPMailer::ENCRYPTION_STARTTLS; Enable TLS encryption, `PHPMailer::ENCRYPTION_SMTPS` also accepted
$mail->Port = 587; // TCP port to connect to
//Recipients
$mail->setFrom('test@makitweb.com', 'Yogesh singh');
$mail->addAddress('Recipient email-id', 'Recipient name'); // Add a recipient
// Content
$mail->isHTML(true); // Set email format to HTML
$mail->Subject = 'Send email using SMTP with PHPmailer';
$mail->Body = 'A test email from <a href="https://makitweb.com">maktiweb.com</a>';
$mail->AltBody = 'A test email from makitweb.com'; // Plain text for non-HTML mail clients
// Attachement
$mail->addAttachment('upload/file.pdf');
$mail->addAttachment('upload/image.png', 'image 1'); // Optional name
$mail->send();
echo 'Message has been sent';
} catch (Exception $e) {
echo "Message could not be sent. Mailer Error: {$mail->ErrorInfo}";
}
Obtenha os detalhes de SMTP do cPanel se você não tiver e use-o para configurar o PHPMailer. Habilite a depuração atribuindo 2 a $mail->SMTPDebug
se obtiver um problema ao enviar o e-mail.
Fonte: https://makitweb.com
1659609060
PHPMailer é uma biblioteca PHP que possui uma função embutida para enviar e-mails com segurança e facilidade usando PHP do servidor.
Mail é uma funcionalidade útil no site.
Ele é usado para verificação do usuário, senha esquecida, envio de informações, etc.
Neste tutorial, mostro como enviar e-mails usando o servidor SMTP com PHPmailer em PHP.
composer require phpmailer/phpmailer
autoload.php
arquivo no vendor
diretório.Set Up Mail Client
.NOTA – Pode diferir de acordo com o servidor.
Importe PHPMailer
, Exception
classifique e inclua 'vendor/autoload.php'
.
<?php
use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\Exception;
// Load Composer's autoloader
require 'vendor/autoload.php';
Crie um objeto de PHPMailer
.
// Instantiation and passing `true` enables exceptions
$mail = new PHPMailer(true);
Atribua 0 a $mail->SMTPDebug
para desabilitar a depuração. Para habilitar o passe 2.
$mail->SMTPDebug = 0; // 0 - Disable Debugging, 2 - Responses received from the server
Especifique o host do servidor em $mail->Host
, nome de usuário em $mail->Username
e senha em $mail->Password
. Atribuir e para . 'tls'
_$mail->SMTPSecure587$mail->Port
NOTA – Todo este valor é obtido do passo anterior.
$mail->Host = 'mail.makitweb.com'; // Specify main and backup SMTP servers
$mail->SMTPAuth = true; // Enable SMTP authentication
$mail->Username = 'test@makitweb.com'; // SMTP username
$mail->Password = 'password'; // SMTP password
$mail->SMTPSecure = 'tls';//PHPMailer::ENCRYPTION_STARTTLS; Enable TLS encryption, `PHPMailer::ENCRYPTION_SMTPS` also accepted
$mail->Port = 587; // TCP port to connect to
Especifique o email-id e o nome do remetente e o email-id e o nome do $mail->setFrom()
destinatário em $mail->addAddress()
.
$mail->setFrom('test@makitweb.com', 'Yogesh singh');
$mail->addAddress('Recipient email-id', 'Recipient name'); // Add a recipient
Especifique o assunto do correio e o corpo em $mail->Subject
, $mail->Body
e $mail->AltBody
.
$mail->isHTML(true); // Set email format to HTML
$mail->Subject = 'Send email using SMTP with PHPmailer';
$mail->Body = 'A test email from <a href="https://makitweb.com">maktiweb.com</a>';
$mail->AltBody = 'A test email from makitweb.com'; // Plain text for non-HTML mail clients
Anexar arquivo usando o $mail->addAttachment()
método. Você pode especificar o nome do arquivo usando o 2º parâmetro.
$mail->addAttachment('upload/file.pdf');
$mail->addAttachment('upload/image.png', 'image 1'); // Optional name
Ligue $mail->send()
para enviar uma solicitação.
Código concluído
<?php
// Import PHPMailer classes into the global namespace
// These must be at the top of your script, not inside a function
use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\Exception;
// Load Composer's autoloader
require 'vendor/autoload.php';
// Instantiation and passing `true` enables exceptions
$mail = new PHPMailer(true);
try {
//Server settings
$mail->SMTPDebug = 0; // 0 - Disable Debugging, 2 - Responses received from the server
$mail->isSMTP(); // Set mailer to use SMTP
$mail->Host = 'mail.makitweb.com'; // Specify main and backup SMTP servers
$mail->SMTPAuth = true; // Enable SMTP authentication
$mail->Username = 'test@makitweb.com'; // SMTP username
$mail->Password = 'password'; // SMTP password
$mail->SMTPSecure = 'tls';//PHPMailer::ENCRYPTION_STARTTLS; Enable TLS encryption, `PHPMailer::ENCRYPTION_SMTPS` also accepted
$mail->Port = 587; // TCP port to connect to
//Recipients
$mail->setFrom('test@makitweb.com', 'Yogesh singh');
$mail->addAddress('Recipient email-id', 'Recipient name'); // Add a recipient
// Content
$mail->isHTML(true); // Set email format to HTML
$mail->Subject = 'Send email using SMTP with PHPmailer';
$mail->Body = 'A test email from <a href="https://makitweb.com">maktiweb.com</a>';
$mail->AltBody = 'A test email from makitweb.com'; // Plain text for non-HTML mail clients
// Attachement
$mail->addAttachment('upload/file.pdf');
$mail->addAttachment('upload/image.png', 'image 1'); // Optional name
$mail->send();
echo 'Message has been sent';
} catch (Exception $e) {
echo "Message could not be sent. Mailer Error: {$mail->ErrorInfo}";
}
Obtenha os detalhes de SMTP do cPanel se você não tiver e use-o para configurar o PHPMailer. Habilite a depuração atribuindo 2 a $mail->SMTPDebug
se obtiver um problema ao enviar o e-mail.
Fonte: https://makitweb.com
1597820991
Looking to develop a PHP based website from scratch or revamp your existing website?
HourlyDeveloper.io has always been an industry leader for companies and business owners looking to hire PHP web developer. By choosing to Hire PHP Developer from our company, you can always expect the best results. Our PHP services and solutions are always flexible which means that no matter the nature of your project, you can always count on us for getting the best PHP expertise.
Consult with our experts: https://bit.ly/3aEGxPy
#hire php developer #php developer #php development company #php development services #php development #php
1617276472
A framework that can drastically cut down the requirement to write original code to develop the web apps as per your requirement is PHP Framework. PHP frameworks offer code libraries for commonly used functions to reduce the development time.
Want to use PHP Web Frameworks for your web applications?
WebClues Infotech offers a service to hire dedicated PHP developers for all of the below-mentioned frameworks
Not sure which framework to use for your PHP web application?
Schedule Interview with PHP Developer https://bit.ly/3dsTWf0
Email: sales@webcluesinfotech.com
#hire php developer #hire php web developers #hire php developer in 2021 #hire php developers & dedicated php programmers #hire php developers india #hire and outsource freelance php developers
1593154878
Looking to hire affordable yet experienced PHP developers?
Hire Dedicated PHP Developer, who can convert your idea to reality, within the stipulated time frame. HourlyDeveloper.io expertise & experience as the top PHP development company put us above our competitors, in many ways. We have some of the top PHP developers in the industry, which can create anything you can imagine, that too, at the most competitive prices.
Consult with our experts:- https://bit.ly/2NpKnB8
#hire dedicated php developer #php developers #php development company #php development services #php development #php developer
1613990718
ValueCoders is a leading PHP app development company that focuses on building robust, secure & scalable web applications for start-ups, enterprises, and entrepreneurs.
We have 16+ years of experience and have delivered custom PHP web development solutions to 2500+ global clients catering industry verticals, including healthcare, adtech, eLearning, data analysis, Fintech, eCommerce, etc
#hire php developer #hire a php developer in india #hire dedicated php programmers #hire php coders #php developer in india #php developers for hire