phpmailer example php

<?php

require_once('class.phpmailer.php');

$mailer = new PHPMailer();
$mailer->IsSMTP();
$mailer->SMTPDebug = 1;
$mailer->Port = 587; //Indica a porta de conexão 
$mailer->Host = 'smtplw.com.br';//Endereço do Host do SMTP 
$mailer->SMTPAuth = true; //define se haverá ou não autenticação 
$mailer->Username = 'smtplocaweb'; //Login de autenticação do SMTP
$mailer->Password = 'Gwb9etA323'; //Senha de autenticação do SMTP
$mailer->FromName = 'Bart S. Locaweb'; //Nome que será exibido
$mailer->From = '[email protected]'; //Obrigatório ser 
a mesma caixa postal configurada no remetente do SMTP
$mailer->AddAddress('[email protected]','Nome do 
destinatário');
//Destinatários
$mailer->Subject = 'Teste enviado através do PHP Mailer 
SMTPLW';
$mailer->Body = 'Este é um teste realizado com o PHP Mailer 
SMTPLW';
if(!$mailer->Send())
{
echo "Message was not sent";
echo "Mailer Error: " . $mailer->ErrorInfo; exit; }
print "E-mail enviado!"
?>


4
2
Daniel Hu 95 points

                                    &lt;?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\SMTP;
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-&gt;SMTPDebug = SMTP::DEBUG_SERVER;                      // Enable verbose debug output
    $mail-&gt;isSMTP();                                            // Send using SMTP
    $mail-&gt;Host       = 'smtp1.example.com';                    // Set the SMTP server to send through
    $mail-&gt;SMTPAuth   = true;                                   // Enable SMTP authentication
    $mail-&gt;Username   = '[email protected]';                     // SMTP username
    $mail-&gt;Password   = 'secret';                               // SMTP password
    $mail-&gt;SMTPSecure = PHPMailer::ENCRYPTION_STARTTLS;         // Enable TLS encryption; `PHPMailer::ENCRYPTION_SMTPS` encouraged
    $mail-&gt;Port       = 587;                                    // TCP port to connect to, use 465 for `PHPMailer::ENCRYPTION_SMTPS` above

    //Recipients
    $mail-&gt;setFrom('[email protected]', 'Mailer');
    $mail-&gt;addAddress('[email protected]', 'Joe User');     // Add a recipient
    $mail-&gt;addAddress('[email protected]');               // Name is optional
    $mail-&gt;addReplyTo('[email protected]', 'Information');
    $mail-&gt;addCC('[email protected]');
    $mail-&gt;addBCC('[email protected]');

    // Attachments
    $mail-&gt;addAttachment('/var/tmp/file.tar.gz');         // Add attachments
    $mail-&gt;addAttachment('/tmp/image.jpg', 'new.jpg');    // Optional name

    // Content
    $mail-&gt;isHTML(true);                                  // Set email format to HTML
    $mail-&gt;Subject = 'Here is the subject';
    $mail-&gt;Body    = 'This is the HTML message body &lt;b&gt;in bold!&lt;/b&gt;';
    $mail-&gt;AltBody = 'This is the body in plain text for non-HTML mail clients';

    $mail-&gt;send();
    echo 'Message has been sent';
} catch (Exception $e) {
    echo &quot;Message could not be sent. Mailer Error: {$mail-&gt;ErrorInfo}&quot;;
}

4 (2 Votes)
0
Are there any code examples left?
Create a Free Account
Unlock the power of data and AI by diving into Python, ChatGPT, SQL, Power BI, and beyond.
Sign up
Develop soft skills on BrainApps
Complete the IQ Test
Relative searches
how to use phpmailer as include can i use phpmailer in funtion PHPMailer/PHPMailer/PHPMailer() php mailer example phpmailer as function php form with phpmailer new PHPMailer phpmailer configuration php.ini phpmailer cc send mail using phpmailer how does phpmailer work phpmailer equivalent from in phpmailer phpmailer include phpmailer word phpmailer wor how to use phpmailer in php php sendmail localhost phpmailer phpmailer code in php htmlmail php phpmailer with html include phpmailer phpmailer using web mail phpmailer form phpmailer for php 7 phpmailer html phpmailer guide php new PHPmailer(); phpmailer library phpmailer log phpmailer email masuk phpmailer config php how to use phpmailer in localhost how to send php page in email phpmailer phpmailer in php phpmailer html mail design que es phpmailer Class 'PHPMailer\PHPMailer\PHPMailer phpmailer example in php example phpmailer install phpmailer/class.phpmailer.php use phpmailer to send emails using phpmailer with smtp phpmailer php 7 phpmailer help phpmailer forum add phpmailer phpmailer php mvc php include PHPMailer send html phpmailer PHPMailer mail use html phpmailer send html phpmailer using sendmail phpmailer setup for html how to integrate phpmailer in php using phpmailer phpmailer doc how to send email using phpmailer phpmailer smtp example phpmailer.php wordpress phpmailer send from class phpmailer phpmailer server PHPMailer inbox phpmailer email setup phpmailer in function phpmailer send email with example phpmailer local mail server phpmailer for php 5.4 phpmailer code PHPMailer use in html project how to send email phpmailer phpmailer html email sending emails from phpmailer add php on html phpmailer phpmailer configuration phpmailer project phpmailer wordpress php phpmailer php 5 phpmailer examples phpmailer connect() how to send an email using phpmailer send mail using phpmailer from localhost phpmailer mail phpmailer works on server ? phpmailer mvc php phpmailer function in php using phpmailer into function phpmailer example html phpmail example PHPMailer web server use phpmailer in php phpmailer setup phpmailer simples mail send phpmailer example\ phpmailer from phpmailer basic example PHPMailer / PHPMailer install and use phpmailer in my project phpmailer using mail server sending html in PHPMailer simple mail using phpmailer phpmailer in a function phpmailer in functions.php phpmailer html email example phpmailer log mails sendmailer php include PHPMAILER php 7.3 phpmailer sample code using php phpmailer smtp example php add phpmailer to php project phpmailer html form how to add phpmailer in php phpmailer cc mail phpmailer tutorial how to setup phpmailer phpmailer documentation phpmailer function phpmailer example php php PHPMailer how to use phpmailer function in php how to use phpmailer function phpmailer send email phpmailer php phpmailer is html phpmailer send mail how to use phpmailer to send emails in php phpmailer php mailer mail() function php mailer mail() php deployer php mailer with smtp php smtp library mailer.php Source.php mailer PHPMailer - PHP SMTP domainesia phpmailer install sendMail in php phpmailer code to check if mail is not valid copia oculta phpmailer phpmailer install composer github PHP Mailer send email without email account on server phpmailer 2.3 phpmailer download download phpmailer latest version php mail library example smtp email composer php 6.0 smtp with phpmailer phpmailer ses smtp mailer php requirements setting up php mailer class Mailer phpmailer smtp php phpmailer from http phpmailer library for laravel can phpmailer receive to the host class phpmailer php 7 how to set from address in phpmailer phpmailer response phpmailer 5.2 stable mail could not be sent github phpmailer github how to run php mailer phpmailer how to use how to use $toEmail in phpmailer phpmailer in php smarty download phpmailer for core php mail server that works well with phpmailer using sendmail in php phpmailer for php 7.3 how to use php mailer html phpmailer phpmailerautoload server example phpmailer master install phpmailer phpmailer send with api clean phpmailer code phpmailer source code download example php mailer basic usage phpmailer don't send copy how to use phpmailer phpmailer example online phpmailer with composer is html phpmailer send authrised email phpmailer file what is phpmailer send email from smtp php without library php github mailer php mailer npm php mailer phpmanual phpmailer if being used send mail php package smtp mail php code download auto send email php core php phpmaier php mailer in php send email phpmailer is send html code in email sending smto mail with phpmailer smtp php mailer for core php phpmailer for core php phpmailer smtp settings in php 7 There was an error while loading /apis/dashboard?authuser=1&amp;folder=organizationId=project=phpmailer. phpmailer dependencies phpmailer areas for improvement phpmailer community does phpmailer use mail function phpmailer library download Class 'PHPMailer\PHPMailer how to send order details using email phpmailer phpmaile() php smtp mail mailer download php smtp php php maeler how to use phpmailer in my html code how to use php mailer in my html code mail.php smtp how to right php inside phpmailer body phpmailer prerequisites send mail phpmailer php Mail class phpmailer with smtp php mailer phpmailer html github php mailler php smtp mailer how to put php in phpmailer how to send email with php mailer send email library php email library php enable html in phpmailer phpmailer from email address php 7 email class example of mail with phpmailer php smtp email php mail autoloader code PHPMailer 6.0.7 removes dot in mailadress PHPMailer.php smtp email php PHPMailer functions free download smtp class do i need all file in phpmailer mailser phpmailer WHERE IS PHP MAILER php email package phpmailer smtp phpmailer master phpmailer setfrom from form entered email mailer php sendmail composer phpmailer php example phpmailer core php code phpmailer smtp core php email class php mailer php script phpmailer library basic installion EMAIL PROVIDERS USED TO SEND EMILS IN PHP library smtp php library smtplib php send email phpmailer running phpmailer on an apache server phpmailer smtp mail php php email libraries download phpmailer php mail plugin how to send a php code in an email latest php mailer smpt php mails php mailer usage php smtp mail library smtp php mail smtp mail on server phpmailer php email library contact email using phpmailer contact email usinfphpmailer class.phpmailer.php phpmailer download for php phpmailer attachment string example phpmailer tutorial php php mailer githu phpmailer attachment phpauto mailer smtp mailer php send email with phpmailer send email with php mailer simple php mailer script php mail library php mailer smtp php mailer in php phpmailer usage php PHP mail mailer PHPMailer github html use PHPMailer\PHPMailer\PHPMailer; use PHPMailer\PHPMailer\SMTP; use PHPMailer\PHPMailer\Exception; php mailter php mailer to span solve mailer() phpmailer mailer() php mail php mailer github php email recieve library php email send library php mailere php mailes downloaded php mailer php emailer phpmailer function download download php mailer php mailer download documentation send mail using phpmailer downlaod php mailer script free phpmailer phpmailer example use phpmailer use PHPMailer\PHPMailer\PHPMailer; require php mailer phpmailer with class php phpmailer class php download phpmailer for ubuntu set up php mailer php mailer download php mailer code addAttachment phpmailer docs php mailer file phpmailer github phpmailer code 10 languages that can send mailes in html upload to email with php mailer php mailer library PHPMailer 5.2 example php mailing libraris class.phpmailer.php download php mailer script download php mail composer php mailer github php mailer download phpmailer library $mail = new PHPMailer; phpmailer 6 example phpmailer tutorial 2020 php mailer html email php mailer function what is php mailer what is a php mailer simple example phpmailer
Made with love
This website uses cookies to make IQCode work for you. By using this site, you agree to our cookie policy

Welcome Back!

Sign up to unlock all of IQCode features:
  • Test your skills and track progress
  • Engage in comprehensive interactive courses
  • Commit to daily skill-enhancing challenges
  • Solve practical, real-world issues
  • Share your insights and learnings
Create an account
Sign in
Recover lost password
Or log in with

Create a Free Account

Sign up to unlock all of IQCode features:
  • Test your skills and track progress
  • Engage in comprehensive interactive courses
  • Commit to daily skill-enhancing challenges
  • Solve practical, real-world issues
  • Share your insights and learnings
Create an account
Sign up
Or sign up with
By signing up, you agree to the Terms and Conditions and Privacy Policy. You also agree to receive product-related marketing emails from IQCode, which you can unsubscribe from at any time.
Creating a new code example
Code snippet title
Source