The classic email sending library for PHP

Overview

PHPMailer

PHPMailer – A full-featured email creation and transfer class for PHP

Test status Latest Stable Version Total Downloads License API Docs

Features

  • Probably the world's most popular code for sending email from PHP!
  • Used by many open-source projects: WordPress, Drupal, 1CRM, SugarCRM, Yii, Joomla! and many more
  • Integrated SMTP support – send without a local mail server
  • Send emails with multiple To, CC, BCC and Reply-to addresses
  • Multipart/alternative emails for mail clients that do not read HTML email
  • Add attachments, including inline
  • Support for UTF-8 content and 8bit, base64, binary, and quoted-printable encodings
  • SMTP authentication with LOGIN, PLAIN, CRAM-MD5, and XOAUTH2 mechanisms over SMTPS and SMTP+STARTTLS transports
  • Validates email addresses automatically
  • Protects against header injection attacks
  • Error messages in over 50 languages!
  • DKIM and S/MIME signing support
  • Compatible with PHP 5.5 and later, including PHP 8.0
  • Namespaced to prevent name clashes
  • Much more!

Why you might need it

Many PHP developers need to send email from their code. The only PHP function that supports this directly is mail(). However, it does not provide any assistance for making use of popular features such as encryption, authentication, HTML messages, and attachments.

Formatting email correctly is surprisingly difficult. There are myriad overlapping (and conflicting) standards, requiring tight adherence to horribly complicated formatting and encoding rules – the vast majority of code that you'll find online that uses the mail() function directly is just plain wrong, if not unsafe!

The PHP mail() function usually sends via a local mail server, typically fronted by a sendmail binary on Linux, BSD, and macOS platforms, however, Windows usually doesn't include a local mail server; PHPMailer's integrated SMTP client allows email sending on all platforms without needing a local mail server. Be aware though, that the mail() function should be avoided when possible; it's both faster and safer to use SMTP to localhost.

Please don't be tempted to do it yourself – if you don't use PHPMailer, there are many other excellent libraries that you should look at before rolling your own. Try SwiftMailer , Laminas/Mail, ZetaComponents etc.

License

This software is distributed under the LGPL 2.1 license, along with the GPL Cooperation Commitment. Please read LICENSE for information on the software availability and distribution.

Installation & loading

PHPMailer is available on Packagist (using semantic versioning), and installation via Composer is the recommended way to install PHPMailer. Just add this line to your composer.json file:

"phpmailer/phpmailer": "^6.2"

or run

composer require phpmailer/phpmailer

Note that the vendor folder and the vendor/autoload.php script are generated by Composer; they are not part of PHPMailer.

If you want to use the Gmail XOAUTH2 authentication class, you will also need to add a dependency on the league/oauth2-client package in your composer.json.

Alternatively, if you're not using Composer, you can download PHPMailer as a zip file, (note that docs and examples are not included in the zip file), then copy the contents of the PHPMailer folder into one of the include_path directories specified in your PHP configuration and load each class file manually:

<?php
use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\Exception;

require 'path/to/PHPMailer/src/Exception.php';
require 'path/to/PHPMailer/src/PHPMailer.php';
require 'path/to/PHPMailer/src/SMTP.php';

If you're not using the SMTP class explicitly (you're probably not), you don't need a use line for the SMTP class. Even if you're not using exceptions, you do still need to load the Exception class as it is used internally.

Legacy versions

PHPMailer 5.2 (which is compatible with PHP 5.0 — 7.0) is no longer supported, even for security updates. You will find the latest version of 5.2 in the 5.2-stable branch. If you're using PHP 5.5 or later (which you should be), switch to the 6.x releases.

Upgrading from 5.2

The biggest changes are that source files are now in the src/ folder, and PHPMailer now declares the namespace PHPMailer\PHPMailer. This has several important effects – read the upgrade guide for more details.

Minimal installation

While installing the entire package manually or with Composer is simple, convenient, and reliable, you may want to include only vital files in your project. At the very least you will need src/PHPMailer.php. If you're using SMTP, you'll need src/SMTP.php, and if you're using POP-before SMTP (very unlikely!), you'll need src/POP3.php. You can skip the language folder if you're not showing errors to users and can make do with English-only errors. If you're using XOAUTH2 you will need src/OAuth.php as well as the Composer dependencies for the services you wish to authenticate with. Really, it's much easier to use Composer!

A Simple Example

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

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

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

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

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

You'll find plenty to play with in the examples folder, which covers many common scenarios including sending through gmail, building contact forms, sending to mailing lists, and more.

If you are re-using the instance (e.g. when sending to a mailing list), you may need to clear the recipient list to avoid sending duplicate messages. See the mailing list example for further guidance.

That's it. You should now be ready to use PHPMailer!

Localization

PHPMailer defaults to English, but in the language folder you'll find many translations for PHPMailer error messages that you may encounter. Their filenames contain ISO 639-1 language code for the translations, for example fr for French. To specify a language, you need to tell PHPMailer which one to use, like this:

//To load the French version
$mail->setLanguage('fr', '/optional/path/to/language/directory/');

We welcome corrections and new languages – if you're looking for corrections, run the PHPMailerLangTest.php script in the tests folder and it will show any missing translations.

Documentation

Start reading at the GitHub wiki. If you're having trouble, head for the troubleshooting guide as it's frequently updated.

Examples of how to use PHPMailer for common scenarios can be found in the examples folder. If you're looking for a good starting point, we recommend you start with the Gmail example.

To reduce PHPMailer's deployed code footprint, examples are not included if you load PHPMailer via Composer or via GitHub's zip file download, so you'll need to either clone the git repository or use the above links to get to the examples directly.

Complete generated API documentation is available online.

You can generate complete API-level documentation by running phpdoc in the top-level folder, and documentation will appear in the docs folder, though you'll need to have PHPDocumentor installed. You may find the unit tests a good reference for how to do various operations such as encryption.

If the documentation doesn't cover what you need, search the many questions on Stack Overflow, and before you ask a question about "SMTP Error: Could not connect to SMTP host.", read the troubleshooting guide.

Tests

PHPMailer tests use PHPUnit 9, with a polyfill to let 9-style tests run on older PHPUnit and PHP versions.

Test status

If this isn't passing, is there something you can do to help?

Security

Please disclose any vulnerabilities found responsibly – report security issues to the maintainers privately.

See SECURITY and PHPMailer's security advisories on GitHub.

Contributing

Please submit bug reports, suggestions and pull requests to the GitHub issue tracker.

We're particularly interested in fixing edge-cases, expanding test coverage and updating translations.

If you found a mistake in the docs, or want to add something, go ahead and amend the wiki – anyone can edit it.

If you have git clones from prior to the move to the PHPMailer GitHub organisation, you'll need to update any remote URLs referencing the old GitHub location with a command like this from within your clone:

git remote set-url upstream https://github.com/PHPMailer/PHPMailer.git

Please don't use the SourceForge or Google Code projects any more; they are obsolete and no longer maintained.

Sponsorship

Development time and resources for PHPMailer are provided by Smartmessages.net, the world's only privacy-first email marketing system.

Smartmessages.net privacy-first email marketing logo

Donations are very welcome, whether in beer 🍺 , T-shirts 👕 , or cold, hard cash 💰 . Sponsorship through GitHub is a simple and convenient way to say "thank you" to PHPMailer's maintainers and contributors – just click the "Sponsor" button on the project page. If your company uses PHPMailer, consider taking part in Tidelift's enterprise support programme.

PHPMailer For Enterprise

Available as part of the Tidelift Subscription.

The maintainers of PHPMailer and thousands of other packages are working with Tidelift to deliver commercial support and maintenance for the open source packages you use to build your applications. Save time, reduce risk, and improve code health, while paying the maintainers of the exact packages you use. Learn more.

Changelog

See changelog.

History

  • PHPMailer was originally written in 2001 by Brent R. Matzelle as a SourceForge project.
  • Marcus Bointon (coolbru on SF) and Andy Prevost (codeworxtech) took over the project in 2004.
  • Became an Apache incubator project on Google Code in 2010, managed by Jim Jagielski.
  • Marcus created his fork on GitHub in 2008.
  • Jim and Marcus decide to join forces and use GitHub as the canonical and official repo for PHPMailer in 2013.
  • PHPMailer moves to the PHPMailer organisation on GitHub in 2013.

What's changed since moving from SourceForge?

  • Official successor to the SourceForge and Google Code projects.
  • Test suite.
  • Continuous integration with Github Actions.
  • Composer support.
  • Public development.
  • Additional languages and language strings.
  • CRAM-MD5 authentication support.
  • Preserves full repo history of authors, commits and branches from the original SourceForge project.
Comments
  • PHPMailer gmail_xoauth.phps example from github

    PHPMailer gmail_xoauth.phps example from github

    I have been trying to get the gmail_xoauth.phps example running from the github site for a number of days now following these instructions.

    https://github.com/PHPMailer/PHPMailer/wiki/Using-Gmail-with-XOAUTH2

    I have repeated the instructions faithfully and googled the error and followed the suggestions on this forum to no avail.

    I always end with "SMTP ERROR: AUTH command failed: 334".

    (The format presented at the google developers site is now slightly different from that shown in the instructions.)

    The only difference from the instructions up to the point of failure is the absence of 250-CHUNKING in the SERVER -> CLIENT response.

    Here is my current state. Can anyone offer suggestions as to how I can get closer to a solution ? (confidential information replaced by xxxxx)

    The following change was made to php.ini to get to this point. [cURL] curl.cainfo = C:\xampp\php\cacert.pem

    This code was also added to gmail_xoauth.php

    // LAD, 2016-04-05 // unsecure fix for "Warning: stream_socket_enable_crypto(): SSL operation failed with code 1" // see https://github.com/PHPMailer/PHPMailer/issues/368

    $mail->SMTPOptions = array( 'ssl' => array( 'verify_peer' => false, 'verify_peer_name' => false, 'allow_self_signed' => true ) );

    php version = 5.6.15 PHPMailer version = 5.2.14 Apache version = Apache/2.4.17 (Win32) OpenSSL/1.0.2d PHP/5.6.15


    redo steps at https://github.com/PHPMailer/PHPMailer/wiki/Using-Gmail-with-XOAUTH2

    https://console.developers.google.com/project

    Create project project name: phpmailer3 project id: phpmailer3-1273 app engine location: us-central

    Google APIs click Gmail API click Enable Gmail API This API is enabled, but you can't use it in your project until you create credentials. Click "Go to Credentials" to do this now (strongly recommended).

    Now select Credentials from the left-hend menu, then click the Create new Client ID button:

    click Create Credentials button Which API ? Gmail API Calling API from ? Web Server What data ? User data

    click 'What credentials do I need ?' Calling Gmail API from a web server

    2 Create an OAuth 2.0 client ID name: phpmailer3 authorized redirect uri: https://localhost/phpmailer2/get_oauth_token.php

    click 'Create client ID' Created OAuth client 'phpmailer3' Email address '[email protected]' Product name shown to users 'PHPMailer3'

    click 'Continue' Download credentials Client ID xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx.apps.googleusercontent.com

        Download this credential information in JSON format. 
    
    click 'Download'
        client_id.json is downloaded
    

    paste the new values into get_oauth_token.php
    $redirectUri = 'http://localhost/phpmailer2/get_oauth_token.php'; $clientId = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx.apps.googleusercontent.com'; $clientSecret = 'xxxxxxxxxxxxxxxxxxxxxxxx';

    Fetch the token with get_oauth_token.php Refresh Token: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

    paste the new values into gmail_xoauth.php and try again


    SERVER -> CLIENT: 220 smtp.gmail.com ESMTP 31sm483745ioj.17 - gsmtp CLIENT -> SERVER: EHLO localhost SERVER -> CLIENT: 250-smtp.gmail.com at your service, [xx.xxx.xxx.xx] 250-SIZE 35882577 250-8BITMIME 250-STARTTLS 250-ENHANCEDSTATUSCODES 250-PIPELINING 250 SMTPUTF8 CLIENT -> SERVER: STARTTLS SERVER -> CLIENT: 220 2.0.0 Ready to start TLS CLIENT -> SERVER: EHLO localhost SERVER -> CLIENT: 250-smtp.gmail.com at your service, [xx.xxx.xxx.xx] 250-SIZE 35882577 250-8BITMIME 250-AUTH LOGIN PLAIN XOAUTH2 PLAIN-CLIENTTOKEN OAUTHBEARER XOAUTH 250-ENHANCEDSTATUSCODES 250-PIPELINING 250 SMTPUTF8 CLIENT -> SERVER: AUTH XOAUTH2 dXNlcj1sb3JuZWR1ZGxleUBnbWFpbC5jb20BYXV0aD1CZWFyZXIgeWEyOS4udkFKeDE1U1plODFQOHlQLWMwN29qMDFjM0VtT3ZFTTlUMFVHZzV6bFF0dkRUQ0poaWdIVXUydl9fQk1uOGstVDRRAQE= SERVER -> CLIENT: 334 eyJzdGF0dXMiOiI0MDAiLCJzY2hlbWVzIjoiQmVhcmVyIiwic2NvcGUiOiJodHRwczovL21haWwuZ29vZ2xlLmNvbS8ifQ== SMTP ERROR: AUTH command failed: 334 eyJzdGF0dXMiOiI0MDAiLCJzY2hlbWVzIjoiQmVhcmVyIiwic2NvcGUiOiJodHRwczovL21haWwuZ29vZ2xlLmNvbS8ifQ== SMTP Error: Could not authenticate. CLIENT -> SERVER: QUIT SERVER -> CLIENT: 535-5.7.8 Username and Password not accepted. Learn more at535 5.7.8 https://support.google.com/mail/answer/14257 31sm483745ioj.17 - gsmtp SMTP ERROR: QUIT command failed: 535-5.7.8 Username and Password not accepted. Learn more at535 5.7.8 https://support.google.com/mail/answer/14257 31sm483745ioj.17 - gsmtp SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting

    Mailer Error: SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting

    opened by renardrouge 67
  • How to unspoof my own Gmail and iCloud e-mails?

    How to unspoof my own Gmail and iCloud e-mails?

    Hello,

    I use PHPMailer but I do not use STMP because it never works with "switch", therefore, I removed STMP and it worked. But in spite of it having worked, Gmail reported my own e-mails as spoofing messages.

    opened by gusbemacbe 63
  • [5.2.7] Class SMTP not found

    [5.2.7] Class SMTP not found

    Hi just test the very last 5.2.7 (#112 included) and got the error: PHP Fatal error: Class 'SMTP' not found in ./lib/phpmailer/class.phpmailer.php on line 1147

    But I have the PHPMailerAutoload.php on the directory, so I wonder what is wrong here, I've seen that now because of the autoload, the require class.smtp.php is gone so perhpas this is the issue.....some advice on this please ?

    thanks regards

    opened by M-Falken 58
  • PHPMailer not connecting to Office365

    PHPMailer not connecting to Office365

    Hey guys,

    I'm trying to connect to Office365 using the settings given by outlook.office365.com:

    Server: smtp.office365.com Port: 587 Security: TLS

    I tried that but when I use TLS it doesn't connect and when I use STARTTLS I get a Couldn't authenticate.

    I know for sure I'm using the correct Username=>Email and Password, but I can't get it to connect.

    For more information when I have to use a local non secure, no login needed server it works, but when I try a TLS it doesn't.

    Any ideas?

    Thanks.

    opened by jfha73 57
  • Plans for PHPMailer

    Plans for PHPMailer

    This ticket is the roadmap for PHPMailer's future development.

    Now that even PHP 5.3 is now EOL, it's about time to make that the minimum supported version rather than 5.0. This necessarily implies BC breaks, so I propose to name it PHPMailer 6.0.0, following standard semantic versioning policy.

    This means we will be able to use namespaces, switch to a PSR-0 compatible file layout, and provide better integration with composer and other frameworks that use PHPMailer.

    There are quite a few architectural problems in PHPMailer. A good example is issue #36. This is a really simple problem, but it's made difficult by PHPMailer's messy and inconsistent mechanisms for handling headers - sometimes as arrays, sometimes as strings. This leads to knock-on effects like it being difficult to determine what order headers appear in - e.g. the abiity to add extra 'Received' headers first.

    Another area of concern is the increasing spaghetti code involved in the handling of the various preset MIME structures. I propose to break out MIME classes that allow the flexible creation of arbitrary MIME structures, then use them to build presets for the same ease of use we have now. To their credit, this is what some other PHP mail classes (SwiftMailer and Zend Framework) already do.

    There is way too much fixed dependency on the SMTP class. This should be dealt with using dependency injection and interfaces for independent transport classes.

    All of these changes could be wrapped with a class that provides some degree of backward compatibility to minimise upgrade pain.

    Please add any other ideas to this ticket.

    Help wanted 
    opened by Synchro 57
  • PHPMailer 6 styling conundrum

    PHPMailer 6 styling conundrum

    I have a problem with PHPMailer 6.0.7, WAMP, PHP 7.3.3, which I hesitate to call a problem, since it is of my own making, and yet, the code was fine in PHPMailer 5.2.9.

    Instead of generating an email with $mail-> "headers", I use preexisting headers that are designed to work in the PHP mail function. Wanting to retain mail() compatibility, I insert the same headers and almost the full MIMEBody. Thus the message adds up to two strings. $headers and $mheaders.

    $mail->addCustomHeader($headers);
    $mail->addCustomHeader($mheaders);
    

    The Body remains empty (with a space).

    $mail->Body = ' ';

    In its entirety I send:

    $mail->isSMTP();
    $mail->Host = 'myhost.biz';
    $mail->Username = '[email protected]';
    $mail->Password = 'secret';
    $mail->SMTPSecure = 'tls';
    $mail->Port = 587;
    $mail->addAddress($email,$asciiname);
    $mail->Subject = $emailsubject;
    $mail->setFrom($senderemail,$sender);
    $mail->addReplyTo($senderemail,$sender);
    $mail->ReturnPath=$sender;
    $mail->XMailer = ' ';
    $mail->Body = ' ';
    $mail->addCustomHeader('Mime-Version','1.0');
    $mail->addCustomHeader($headers);
    $mail->addCustomHeader($mheaders);
    

    I'm attaching two text email source files graphically illustrating the different outputs with PHPMailer 5.2.9 and 6.0.7 respectively, one, a well-formed email, the other, unreadable by email clients that fail to display the message, that is both plain-text and html.

    529.txt 607.txt

    It isn't precisely a bug. Question: Is there a way of fixing it?

    Thanks.

    opened by tnbnicer 52
  • Line ending problem? v6 and PHP7

    Line ending problem? v6 and PHP7

    I have a problem with emails sent via PHPMailer v6 and PHP7. It looks like a problem with line endings, because there is =0D at the end of each line. However, if I send same email, with same message etc. those symbols are not there.

    This is quite big problem, cause some email clients then show empty message. So for now, v6 is totally useless for me.

    Problem happen with latest PHPMailer v6, but with v5.2.21 email is OK

    opened by arxeiss 48
  • Multiple Messages Sent

    Multiple Messages Sent

    I'm a newbie here and just wondering if anyone could tell me why the mailer is sending me 3 instances of the same email to 1 recipient? Any assistance would be greatly appreciated

    opened by ken-jones1 44
  • SMTP connect() failed.

    SMTP connect() failed.

    Hi, I am using the gmail smtp server (smtp.gmail.com), with my gmail (free) username and password but each time I am getting the following error

    2014-08-31 17:13:00 Connection: opening to ssl://smtp.gmail.com:465, t=10, opt=array ( )
    2014-08-31 17:13:00 SMTP ERROR: Failed to connect to server: Permission denied (13)
    2014-08-31 17:13:00 SMTP connect() failed. array(1) { [0]=> string(46) "SMTP connect() failed.
    

    I have tried with both tls (port=587), and ssl (port=465), but got the same error

    opened by nileshcool 43
  • DKIM Fail since Update 6.1.0

    DKIM Fail since Update 6.1.0

    Hey there,

    since update 6.1.0 the DKIM signature verification isnt working.

    The response in the email-source text is :

    X-DKIM-Status: fail [(adress.com) - 127.0.0.1] X-DKIM-Status: fail [([email protected]) - 127.0.0.1] X-DKIM-Status: fail [(adress.com) - 0.0.0.0] X-DKIM-Status: fail [([email protected]) - 0.0.0.0]

    and it should be

    X-DKIM-Status: pass [(adress.com) - 127.0.0.1] X-DKIM-Status: pass [([email protected]) - 127.0.0.1] X-DKIM-Status: pass [(adress.com) - 0.0.0.0] X-DKIM-Status: pass [([email protected]) - 0.0.0.0]

    !IPs and adresses changed ( cause of firm intern data)

    We didnt change anything expect the version. and the key is still valid

    with best regards

    opened by Florian-Sobotka 41
  • Some HTML emails received in Outlook replace every 75th character with an equals (=) sign

    Some HTML emails received in Outlook replace every 75th character with an equals (=) sign

    Basing this one off of closed issue #464. It seems that the behavior has regressed. The issue did not occur in v5.2.10, but I'm seeing it now after upgrading to v5.2.14 with WordPress 4.4.1 (https://core.trac.wordpress.org/ticket/35212).

    There is a relevant StackOverflow thread here: http://stackoverflow.com/questions/33787777/phpmailer-inserts-equal-sign-every-75th-character/34589032#34589032

    I have attached some examples: Good_Email_Example_5.2.10.txt Bad_Email_Example_5.2.14.txt

    My current workaround is to replace WordPress' core file for PHPMailer with version 5.2.10. As you can imagine this is less than ideal because updates will bring be back up to 5.2.14 where the issue occurs.

    Please let me know how I can help you reproduce this or if I should be submitting this issue somewhere else (like straight to WordPress instead). Thank you!

    opened by Blurn 40
  • XCLIENT implementation

    XCLIENT implementation

    XCLIENT allows a mail server to receive certain parameters (such as ip address, sasl login, etc.) from a trusted source. https://www.postfix.org/XCLIENT_README.html

    This pull request adds XCLIENT capability to PHPMailer. This way PHPMailer can connect to an SMTP server and if trusted can pass these values to the server, for example an already authenticated user will be able to send mail without the need to pass the password but will still be treated as smtp authenticated by the smtp server.

    Sample code:

    $mail = new PHPMailer();
    $mail->isSMTP();
    $mail->SMTPAuth = false;
    $mail->SMTPXClient = [
        'LOGIN' => '[email protected]',
        'ADDR' => '10.10.10.10',
    ];
    

    I would appreciate any comments.

    opened by mta59066 2
  • Website registration verification email is rejected by gmail

    Website registration verification email is rejected by gmail

    The website built on the Linux system uses phpmailer to use gmail as the registration verification code to send the email, but it will still be rejected by other gmail mailboxes. Checking the log shows that the email is sent on behalf (SPF and DKIM are not passed), and the gmail error is 550 7.5. 26, but I have already done the deployment of gmail according to the tutorial, how to deal with it. thanks~

    ==============error log============ host gmail-smtp-in.l.google.com[142.250.138.26] said: 550-5.7.26 This message does not pass authentication checks (SPF and DKIM both 550-5.7.26 do not pass). SPF check for [aspades.xyz] does not pass with ip: 550-5.7.26 [75.127.7.127].To best protect our users from spam, the message has 550-5.7.26 been blocked. Please visit 550-5.7.26 https://support.google.com/mail/answer/81126#authentication for more 550 5.7.26 information. 23-20020aca1117000000b00354eb46fddfsi4821773oir.110 - gsmtp (in reply to end of DATA command)

    opened by kootrya 5
  • Already having the token, send mail using ms office oauth2 authentication

    Already having the token, send mail using ms office oauth2 authentication

    Hi there, is there already a way to authenticate using xoauth2 authentication without the need to get a token? I already have the token and to get PHPMailer to use it I had to:

    • set the AuthType parameter to XOAUTH2; $mail->oauth = $oauthToken;

    • modify the SMTP.php implementation (line 598) like this:

      // $oauth = $OAuth->getOauth64();

      // Adding new lines, username and token base64 encoding
      $oauth = base64_encode(
                    'user=' .
                   $username .
                    "\001auth=Bearer " .
                    $OAuth .
                    "\001\001");
      
    • modify the PHPMailer.php implementation making the $oauth variable (line 365) public public $oauth;

    • set the now available oauth parameter, like this $mail->oauth = $oauthToken;

    This way I was able to authenticate to the MS server and send an email. Maybe there's already another way to do it but I didn't find it.

    opened by nettunodev 3
  • addOrEnqueueAnAddress  setFrom

    addOrEnqueueAnAddress setFrom

    https://github.com/PHPMailer/PHPMailer/blob/9400f305a898f194caff5521f64e5dfa926626f3/src/PHPMailer.php#L1068 https://github.com/PHPMailer/PHPMailer/blob/2f4b684353d89b232e392bf6270261bbc52f315f/src/PHPMailer.php#L1289

    https://github.com/PHPMailer/PHPMailer/blob/9400f305a898f194caff5521f64e5dfa926626f3/src/PHPMailer.php#L1076


    addAddress addCC addBCC addReplyTo addOrEnqueueAnAddress

    setFrom

    Why is addOrEnqueueAnAddress not applied to setFrom function? And only use 'to', 'cc', 'bcc', 'ReplyTo' these four. The logic inside is a bit close.

    opened by ZhangChengLin 1
  • Address header not folded with large number of recipients

    Address header not folded with large number of recipients

    Hi,

    when adding multiple addresses on a To, CC or BCC, it seems that the result is not folded. All separate adresses are checked against the maximum length, but not the resulting output. This leads to an incorrect header being sent.

    In the function addrAppend, there is just an implode, should the result of the implode (along with the other values) als be handled by the encodeHeader function?

    Please advise

    image

    opened by Centridox 3
Releases(v6.7.1)
  • v6.7.1(Dec 8, 2022)

    • Add official support for PHP 8.2 (on release day!)
    • Add PHP 8.3 to test suite with "experimental" status
    • Add ext-openssl to composer suggest list
    • Bump development dependencies
    Source code(tar.gz)
    Source code(zip)
  • v6.7(Dec 5, 2022)

    • Break out boundary definitions into a method (note that boundary format has also changed slightly)
    • Remove MIME preamble to match popular client behaviour, may help with DKIM too
    • Fix handling of trailing whitespace in simple DKIM canonicalisation
    • Fix some possible POP3 auth issues, including a TCP hang (thanks to @czirkoszoltan)
    • Add Azure XOAUTH2 example and docs (thanks to @greew)
    • Preserve errors during disconnect
    • Avoid some PHP 8.1 type issues
    • Update CI to run on Ubuntu 22.04
    Source code(tar.gz)
    Source code(zip)
  • v6.6.5(Oct 7, 2022)

    This is a maintenance release

    • Don't try to issue RSET if there has been a connection error
    • Reject attempts to add folders as attachments
    • Don't suppress earlier error messages on close()
    • Handle Host === null better
    • Update Danish and Polish translations
    • Change recommendation for Microsoft OAuth package to thenetworg/oauth2-azure
    • Bump some GitHub action versions

    Happy Hacktoberfest!

    Source code(tar.gz)
    Source code(zip)
  • v6.6.4(Aug 22, 2022)

    This is a maintenance release.

    • Update Greek translation
    • Add text/csv MIME type
    • Fix DKIM when sending to anonymous group via mail()
    • Improve docs around auth following gmail & MS deprecations
    • Update GitHub action deps
    • Add OpenSSF Scorecard security health metrics
    Source code(tar.gz)
    Source code(zip)
  • v6.6.3(Jun 20, 2022)

    This is a maintenance release.

    • Add an HTML form to the OAuth setup script
    • Minor CS improvements
    • Add Mongolian translation
    • Remove bogus "ch" translation

    The removal of the translation file is effectively a BC break, however, I don't expect it to affect anyone except that small group of users that request error messages in the Chamorro language, but are happy getting them in Chinese instead 😆.

    Source code(tar.gz)
    Source code(zip)
  • v6.6.2(Jun 14, 2022)

    This is a maintenance release.

    • Don't clear errors on RSET, so they can still be obtained when using keepalive
    • Bump some GitHub action versions
    • Fix some tests
    • Fix docs deployment GitHub action
    • Updates to parallel-lint and console highlighter, thanks to @jrfnl
    • 🇺🇦 Slava Ukraini!

    Note that 6.6.1 was not released.

    Source code(tar.gz)
    Source code(zip)
  • v6.6.0(Feb 28, 2022)

    This is a minor feature release.

    Prior to this version, any OAuth provider needed to extend the provided OAuth base class, and this made it difficult to use with libraries other than ones based on the default league client packages. The OAuth property now accepts anything that implements the OAuthProviderInterface, making it much easier to use things like Google's own OAuth classes. Existing implementations that extend the provided OAuth base class will still work, as that base class now implements this interface too. Thanks to @pdscopes.

    When TLS errors occurred in PHPMailer, the error messages were often missing important info that might help diagnose/solve the problem. These error messages should now be more informative. A minor change is that a TLS error on SMTP connect will now throw an exception if exceptions are enabled. Thanks to @miken32.

    Source code(tar.gz)
    Source code(zip)
  • v6.5.4(Feb 17, 2022)

    This is a maintenance release.

    The change in how shell escaping is handled should not create any BC issues. What used to fail accidentally in potentially unsafe shell situations will now fail deliberately! Note to hosting providers: don't disable escapeshellarg and escapeshellcmd; it's not safe!

    • If we can't use escaping functions, refuse to do unsafe things
    • Avoid PHP 8.1 trim issue
    • Add tests for XMailer
    • Fix bug in use of CharSet property
    • Fix bug in file upload example
    • Update dev dependencies
    Source code(tar.gz)
    Source code(zip)
  • v6.5.3(Nov 25, 2021)

  • v6.5.2(Nov 25, 2021)

    This is a maintenance release.

    • Enable official support for PHP 8.1
    • Enable experimental support for PHP 8.2
    • Fix for PHP 5.6
    • Fix for incorrect options for punyencoding IDNs
    Source code(tar.gz)
    Source code(zip)
  • v6.5.1(Aug 18, 2021)

    This is a maintenance release.

    • Provisional support for PHP 8.1
    • Major overhaul of test suite
    • Add codecov.io coverage reporting
    • Prefer implicit TLS on port 465 as default encryption scheme in examples, as per RFC8314
    • Fix potential noisy output from IMAP address parser
    • Stricter checking of custom MessageID validity
    • Replace invalid default From address
    • Support fallback for languages, so a request for pt_xx will fall back to pt rather than the default en.
    • Support multi-line RFC2047-encoded addresses in parseAddresses
    • Improved Japanese translation

    Many thanks to @jrfnl for all her work.

    Source code(tar.gz)
    Source code(zip)
  • v6.5.0(Jun 16, 2021)

    This is a security release.

    • SECURITY Fixes CVE-2021-34551, a complex RCE affecting Windows hosts. See SECURITY.md for details.
    • The fix for this issue changes the way that language files are loaded. While they remain in the same PHP-like format, they are processed as plain text, and any code in them will not be run, including operations such as concatenation using the . operator.
    • Deprecation The current translation file format using PHP arrays is now deprecated; the next major version will introduce a new format.
    • SECURITY Fixes CVE-2021-3603 that may permit untrusted code to be run from an address validator. See SECURITY.md for details.
    • The fix for this issue includes a minor BC break: callables injected into validateAddress, or indirectly through the $validator class property, may no longer be simple strings. If you want to inject your own validator, provide a closure instead of a function name.
    • Haraka message ID strings are now recognised

    Thanks to Vikrant Singh Chauhan, listensec.com, and the WordPress security team for reporting and assistance with this release.

    Source code(tar.gz)
    Source code(zip)
  • v6.4.1(Apr 29, 2021)

    This is a security release.

    • SECURITY Fixes CVE-2020-36326, a regression of CVE-2018-19296 object injection introduced in 6.1.8, see SECURITY.md for details
    • Reject more file paths that look like URLs, matching RFC3986 spec, blocking URLS using schemes such as ssh2
    • Ensure method signature consistency in doCallback calls
    • Ukrainian language update
    • Add composer scripts for checking coding standards and running tests

    Thanks to Fariskhi Vidyan for the report and assistance, and Tidelift for support.

    Source code(tar.gz)
    Source code(zip)
  • v6.4.0(Mar 31, 2021)

    This is a maintenance release. The changes introduced in 6.3.0 for setting an envelope sender automatically when using mail() caused problems, especially in WordPress, so this change has been reverted. It gets a minor version bump as it's a change in behaviour, but only back to what 6.2.0 did. See #2298 for more info.

    Other changes:

    • Check for the mbstring extension before decoding addresss in parseAddress, so it won't fail if you don't have it installed
    • Add Serbian Latin translation (sr_latn)
    • Enrol PHPMailer in Tidelift, because supporting open-source is important!
    Source code(tar.gz)
    Source code(zip)
  • v6.3.0(Feb 19, 2021)

    This is a maintenance release.

    • Handle early connection errors such as 421 during connection and EHLO states
    • Switch to Github Actions for CI
    • Generate debug output for mail(), sendmail, and qmail transports. Enable using the same mechanism as for SMTP: set SMTPDebug > 0
    • Make the mail() and sendmail transports set the envelope sender the same way as SMTP does, i.e. use whatever From is set to, only falling back to the sendmail_from php.ini setting if From is unset. This avoids errors from the mail() function if Sender is not set explicitly and php.ini is not configured. This is a minor functionality change, so bumps the minor version number.
    • Extend parseAddresses to decode encoded names, improve tests
    Source code(tar.gz)
    Source code(zip)
  • v6.2.0(Nov 25, 2020)

    This is a maintenance release. With this release, PHPMailer gains official PHP 8 compatibility; earlier versions worked in PHP 8 pre-releases, but the test suite did not. The considerable rework this required (which also restored tests running on older PHP versions) was done by @jrfnl – thank you very much!

    • PHP 8.0 compatibility
    • Switch from PHP CS Fixer to PHP CodeSniffer for coding standards
    • Create class constants for the debug levels in the POP3 class
    • Improve French, Slovenian, and Ukrainian translations
    • Improve file upload examples so file extensions are retained
    • Resolve PHP 8 line break issues due to a very old PHP bug being fixed
    • Avoid warnings when using old openssl functions
    • Improve Travis-CI build configuration
    Source code(tar.gz)
    Source code(zip)
  • v6.1.8(Oct 9, 2020)

    This is a maintenance release.

    • Mark ext-hash as required in composer.json. This has long been required, but now it will cause an error at install time rather than runtime, making it easier to diagnose
    • Make file upload examples safer
    • Update links to SMTP testing servers
    • Avoid errors when set_time_limit is disabled (you need better hosting!)
    • Allow overriding auth settings for local tests; makes it easy to run tests using HELO
    • Recover gracefully from errors during keepalive sessions
    • Add AVIF MIME type mapping
    • Prevent duplicate To headers in BCC-only messages when using mail()
    • Avoid file function problems when attaching files from Windows UNC paths
    • Improve German, Bahasa Indonesian, Filipino translations
    • Add Javascript-based example
    • Increased test coverage
    Source code(tar.gz)
    Source code(zip)
  • v6.1.7(Jul 14, 2020)

    PHPMailer 6.1.7

    This is a maintenance release.

    • Split SMTP connection into two separate methods
    • Undo BC break in PHP vesions 5.2.3 - 7.0.0 introduced in 6.1.2 when injecting callables for address validation and HTML to text conversion
    • Save response to SMTP welcome banner as other responses are saved
    • Retry stream_select if interrupted by a signal
    Source code(tar.gz)
    Source code(zip)
  • v6.1.6(May 27, 2020)

    PHPMailer 6.1.6

    This is a security release, with some other minor changes. For full details, refer to the advisory.

    • SECURITY Fix insufficient output escaping bug in file attachment names. CVE-2020-13625. Reported by Elar Lang of Clarified Security.
    • Correct Armenian ISO language code from am to hy, add mapping for fallback
    • Use correct timeout property in debug output
    Source code(tar.gz)
    Source code(zip)
  • v5.2.28(Mar 19, 2020)

  • v6.1.5(Mar 14, 2020)

    This is a maintenance release.

    • Reject invalid custom headers that are empty or contain breaks
    • Various fixes for DKIM issues, especially when using mail() transport
    • Drop the l= length tag from DKIM signatures; it's a mild security risk
    • Ensure CRLF is used explicitly when needed, rather than static::$LE
    • Add a method for trimming header content consistently
    • Some minor tweaks to resolve static analyser complaints
    • Check that attachment files are readable both when adding and when sending
    • Work around Outlook bug in mishandling MIME preamble
    • Danish translation improvements
    Source code(tar.gz)
    Source code(zip)
  • v6.1.4(Dec 10, 2019)

    The RFC2047 folding added in 6.1.0 was a little overenthusiastic; It will now only happen when header lines exceed 998 chars.

    • Clean up hostname handling
    • Avoid IDN error on older PHP versions, prep for PHP 8.0
    • Don't force RFC2047 folding unnecessarily
    • Enable tests on full release of PHP 7.4
    Source code(tar.gz)
    Source code(zip)
  • v6.1.3(Nov 21, 2019)

    • Fix an issue preventing injected debug handlers from working
    • Fix an issue relating to connection timeout
    • Add SMTP::MAX_REPLY_LENGTH constant
    • Remove some dev dependencies; phpdoc no longer included
    • Fix an issue where non-compliant servers returning bare codes caused an SMTP hang
    Source code(tar.gz)
    Source code(zip)
  • v6.1.2(Nov 13, 2019)

    • Substantial revision of DKIM header generation
    • Use shorter hashes for auto-generated CID values
    • Fix format of content-id headers, and only use them for inline attachments
    • Remove all use of XHTML
    • Lots of coding standards cleanup
    • API docs are now auto-updated via GitHub actions
    • Fix header separation bug created in 6.1.1
    • Fix misidentification of background attributes in SVG images in msgHTML
    Source code(tar.gz)
    Source code(zip)
  • v6.1.1(Sep 27, 2019)

  • v6.1.0(Sep 27, 2019)

    This is a feature and maintenance release.

    • Multiple bug fixes for folding of long header lines, thanks to @caugner
    • Add support for RFC2387 child element content-type hint in multipart/related structures.
    • Support for Ical event methods other than REQUEST, thanks to @puhr-mde
    • Change header folding and param separation to use spaces instead of tabs
    • Use ; to separate multiple MIME header params
    • Add support for RFC3461 DSN messages
    • IMAP example code fixed
    • Use PHP temp streams instead of temp files
    • Allow for longer SMTP error codes
    • Updated Brazilian Portuguese translation
    • Throw exceptions on invalid encoding values
    • Add Afrikaans translation, thanks to @Donno191
    • Updated Farsi/Persian translation
    • Add PHP 7.4 to test config
    • Remove some ambiguity about setting XMailer property
    • Improve error checking in mailing list example
    • Drop PHP 5.5 from CI config as it's no longer supported by Travis-CI
    • Fix S/MIME signing
    • Add constants for encryption type
    • More consistent use of constants for encryption, charset, encoding
    • Add PHPMailer logo images
    Source code(tar.gz)
    Source code(zip)
  • v6.0.7(Feb 1, 2019)

    This is a maintenance release.

    • Include RedHat GPL Cooperation Commitment - see the COMMITMENT file for details.
    • Don't exclude composer.json from git exports as it breaks composer updates in projects that use PHPMailer
    • Updated Malay translation
    • Fix language tests
    Source code(tar.gz)
    Source code(zip)
  • v6.0.6(Nov 16, 2018)

    • SECURITY Fix potential object injection vulnerability. CVE-2018-19296. Reported by Sehun Oh of cyberone.kr.
    • Added Tagalog translation, thanks to @StoneArtz
    • Added Malagache translation, thanks to @Hackinet
    • Updated Serbian translation, fixed incorrect language code, thanks to @mmilanovic4
    • Updated Arabic translations (@MicroDroid)
    • Updated Hungarian translations
    • Updated Dutch translations
    • Updated Slovenian translation (@filips123)
    • Updated Slovak translation (@pcmanik)
    • Updated Italian translation (@sabas)
    • Updated Norwegian translation (@aleskr)
    • Updated Indonesian translation (@mylastof)
    • Add constants for common values, such as text/html and quoted-printable, and use them
    • Added support for copied headers in DKIM, helping with debugging, and an option to add extra headers to the DKIM signature. See DKIM_sign example for how to use them. Thanks to @gwi-mmuths.
    • Add Campaign Monitor transaction ID pattern matcher
    • Remove deprecated constant and ini values causing warnings in PHP 7.3, added PHP 7.3 build to Travis config.
    • Expanded test coverage
    Source code(tar.gz)
    Source code(zip)
  • v5.2.27(Nov 16, 2018)

    • SECURITY Fix potential object injection vulnerability. CVE-2018-19296. Reported by Sehun Oh of cyberone.kr.

    Note that the 5.2 branch is deprecated and will not receive security updates after 31st December 2018.

    Source code(tar.gz)
    Source code(zip)
  • v6.0.5(Mar 27, 2018)

Owner
PHPMailer
The classic email sending library for PHP
PHPMailer
Mail sending module for Mezzio and Laminas MVC with support for file attachment and template email composition

This module provides an easy and flexible way to send emails from Mezzio and Laminas MVC applications (formerly known as Zend Expressive and Zend MVC). It allows you to pre-configure emails and transports, and then send those emails at runtime.

null 82 Jan 16, 2022
Sending Email via Microsoft Exchange Web Services made Easy!

Send Mail via Exchange Web Services! Sending Email via Microsoft Exchange Web Services (EWS) made easy! Installation Install via Composer composer req

Raju Rayhan 19 Jul 19, 2022
This package adds support for verifying new email addresses: when a user updates its email address, it won't replace the old one until the new one is verified.

Laravel Verify New Email Laravel supports verifying email addresses out of the box. This package adds support for verifying new email addresses. When

Protone Media 300 Dec 30, 2022
Magento 2 Email Catcher or Email Logger Module.

Magento 2 Module Experius email catcher / - logger

Experius 49 Dec 16, 2021
SendPortal - Open-source self-hosted email marketing, subscriber and list management, email campaigns and more

SendPortal includes subscriber and list management, email campaigns, message tracking, reports and multiple workspaces/domains in a modern, flexible and scalable application.

Mettle 1.2k Jan 4, 2023
Cross-language email validation. Backed by a database of over 38 000 throwable email domains.

Cross-language temporary (disposable/throwaway) email detection library. Covers 38038+ fake email providers.

Francois-Guillaume Ribreau 1.4k Jan 9, 2023
Provides a clean and simple way to configure the WordPress-bundled PHPMailer library, allowing you to quickly get started sending mail through a local or cloud based service of your choice

WP PHPMailer provides a clean and simple way to configure the WordPress-bundled PHPMailer library, allowing you to quickly get started sending mail through a local or cloud based service of your choice.

Itineris Limited 61 Dec 6, 2022
This application (class) does the sending of emails used in the phpmailer library

emailsender - PHP Notification library via email using phpMailer This library has the function of sending email using the phpmailer library. Doing thi

Lucas Alcantara Rodrigues Volpati 1 Feb 9, 2022
EmailReplyParser is a PHP library for parsing plain text email content, based on GitHub's email_reply_parser library written in Ruby

EmailReplyParser EmailReplyParser is a PHP library for parsing plain text email content, based on GitHub's email_reply_parser library written in Ruby.

William Durand 606 Dec 8, 2022
CssToInlineStyles is a class that enables you to convert HTML-pages/files into HTML-pages/files with inline styles. This is very usefull when you're sending emails.

CssToInlineStyles class Installation CssToInlineStyles is a class that enables you to convert HTML-pages/files into HTML-pages/files with inline style

Tijs Verkoyen 5.7k Dec 29, 2022
The Mailer component helps sending emails

Mailer Component The Mailer component helps sending emails. Getting Started $ composer require symfony/mailer use Symfony\Component\Mailer\Transport;

Symfony 1.1k Jan 7, 2023
Simple mail sending by PHPMailer and Create your local system.

Simple mail sending by PHPMailer and Create your local system. Send mail zero of cost and also send Attachment like Photo, pdf and multiple files. You should be create a login and verify two steps authentication like OTP, verifications ?? link. PHPMailer make your dreams project eassy and simple also free of cost.

SUSHIL KUMBHAR 2 Dec 8, 2021
A simplified SMPP client lib for sending or receiving smses through SMPP v3.4.

PHP-based SMPP client lib This is a simplified SMPP client lib for sending or receiving smses through SMPP v3.4. In addition to the client, this lib a

Qranio.com 2 Jul 26, 2022
PHP library for parsing plain text email content.

EmailReplyParser EmailReplyParser is a PHP library for parsing plain text email content, based on GitHub's email_reply_parser library written in Ruby.

William Durand 606 Dec 8, 2022
Small PHP library to valid email addresses using a number of methods.

Email Validator Small PHP library to valid email addresses using a number of methods. Features Validates email address Checks for example domains (e.g

James Jackson 154 Dec 31, 2022
📧 Handy email creation and transfer library for PHP with both text and MIME-compliant support.

?? Handy email creation and transfer library for PHP with both text and MIME-compliant support.

Nette Foundation 401 Dec 22, 2022
Library for using online Email providers

Stampie Stampie have been moved to the "Flint" organization in order to get a better collaborative flow. Stampie is a simple API Wrapper for different

Henrik Bjørnskov 32 Oct 7, 2020
Library for using online Email providers

Stampie Stampie is a simple API Wrapper for different email providers such as Postmark and SendGrid. It is very easy to use and to integrate into your

Stampie 288 Dec 31, 2022
Fetch is a library for reading email and attachments, primarily using the POP and IMAP protocols

Fetch Fetch is a library for reading email and attachments, primarily using the POP and IMAP protocols. Installing N.b. A note on Ubuntu 14.04 (probab

Tedious Developments 501 Jan 4, 2023