PHPMailer | The classic email sending library for PHP | Email library

 by   PHPMailer PHP Version: v6.8.0 License: LGPL-2.1

kandi X-RAY | PHPMailer Summary

kandi X-RAY | PHPMailer Summary

PHPMailer is a PHP library typically used in Telecommunications, Media, Media, Entertainment, Messaging, Email applications. PHPMailer has no bugs, it has a Weak Copyleft License and it has medium support. However PHPMailer has 4 vulnerabilities. You can download it from GitHub.

The classic email sending library for PHP

            kandi-support Support

              PHPMailer has a medium active ecosystem.
              It has 19593 star(s) with 9666 fork(s). There are 883 watchers for this library.
              There were 2 major release(s) in the last 12 months.
              There are 29 open issues and 1930 have been closed. On average issues are closed in 88 days. There are 9 open pull requests and 0 closed requests.
              It has a neutral sentiment in the developer community.
              The latest version of PHPMailer is v6.8.0

            kandi-Quality Quality

              PHPMailer has 0 bugs and 0 code smells.

            kandi-Security Security

              PHPMailer has 4 vulnerability issues reported (2 critical, 1 high, 1 medium, 0 low).
              PHPMailer code analysis shows 0 unresolved vulnerabilities.
              There are 0 security hotspots that need review.

            kandi-License License

              PHPMailer is licensed under the LGPL-2.1 License. This license is Weak Copyleft.
              Weak Copyleft licenses have some restrictions, but you can use them in commercial projects.

            kandi-Reuse Reuse

              PHPMailer releases are available to install and integrate.
              Installation instructions, examples and code snippets are available.
              PHPMailer saves you 2115 person hours of effort in developing the same functionality from scratch.
              It has 4834 lines of code, 169 functions and 58 files.
              It has high code complexity. Code complexity directly impacts maintainability of the code.

            Top functions reviewed by kandi - BETA

            kandi has reviewed PHPMailer and discovered the below as its top functions. This is intended to give you an instant insight into PHPMailer implemented functionality, and help decide if they suit your requirements.
            • Create email body
            • Create DKIM
            • Authenticates to the server
            • Get lines from the SMTP connection
            • Connect to the POP3 server
            • Authorise the server
            • Generate the OAuth 64
            • Get an access token .
            • Get error message .
            Get all kandi verified functions for this library.

            PHPMailer Key Features

            No Key Features are available at this moment for PHPMailer.

            PHPMailer Examples and Code Snippets

            No Code Snippets are available at this moment for PHPMailer.

            Community Discussions


            Why PHP PDO bindParam return null if include jQuery file
            Asked 2022-Apr-02 at 20:41

            On every page I have jQuery modal which contains a contact form and which on every page need sent data to different email address. When a form is submitted I need to display successful response using json_encode. Also on every page I use page identifier as $pages_id=1, $pages_id=2, etc., for identify which form is submitted. However, very important, without jQuery file, complete my PHP code it's executed correctly, all data are successfully inserted into database and in Xdebug I also see that code on every line it's executed successfully. But, if I include jQuery file then in Xdebug the value for $pages_id return null. I exactly think at this line of code:



            Answered 2021-Dec-20 at 17:54

            page_id is null in your script because you dont set it in the script.

            So why not just adding an hidden input field in your froms with the page id and then in your PHP code

            $page_id = $_POST['pageId'];

            i think you did not understood ajax correclty. if you post your data to /inc/FormProcess.php it is not like an include before, where you could create variables first and then include it. AJax is like a sub call to the script. it is like if you would open ONLY this scrirpt provided in URL. so at this point you dont have your variables.

            you need to get the variables or send your ajax request NOT to /inc/FormProcess.php but to the script where you define the variable



            How to display all selected Checkboxes in PHPmailer
            Asked 2022-Apr-01 at 20:30

            I was tying to create a checkbox and get all checkboxes that were selected and ues phpmailer to email them to my email. Apparently i can get only 1 value selected from checkboxes out of all selected ones. Sorry if i make ur brain suicide from these indents xd This is my html file :



            Answered 2022-Apr-01 at 20:30

            You need to use array syntax in your checkboxes' name attributes on the form:



            php file size validation
            Asked 2022-Mar-23 at 22:15

            I would like to create in php file size validation for every single file. I used for loop to add attachments, and then created condition to check file, but it's not working. There's no error, but it send mail with oversized attachment, instead of stop. Without the size validation part, it sends mail without any problems.

            For sending I used php mailer.



            Answered 2022-Mar-22 at 14:35

            What I can see here is that you used the "move_upload_file" way earlier before you checked for the file size. And that means the file will be uploaded before checking to see if it's bigger or not. It should be something like this;



            Get Google access token not through the browser
            Asked 2022-Mar-17 at 03:18
            PROBLEM SOLVED

            Finally, I get the refresh_token, by revoking from google account(aka remove the apps access through account).

            Everything goes normal again, and I don't need to solve the problem as the title 'Get Google access token not through the browser'.

            But why I success this time? Because this time I use curl but not thephpleague/oauth2-client way to request auth. I think there must missing some parms when I request auth via thephpleague/oauth2-client.

            Here is a curl way that I get the refresh_token EVERYTIME after I revoke/remove the apps access from account.



            Answered 2022-Mar-16 at 14:25

            First issue: off I think you have miss understood something about refresh tokens.

            If you check the expiration page you will set this

            There is currently a limit of 50 refresh tokens per Google Account per OAuth 2.0 client ID. If the limit is reached, creating a new refresh token automatically invalidates the oldest refresh token without warning. This limit does not apply to service accounts.

            Yes there is a limit of 50 OUTSTANDING refresh tokens for a user. This means if I run your app and authorize it i get a refresh token back. If i run it again i get another refresh token back. I can do this 50 times and your app will have 50 outstanding refresh tokens to my account and they all will work. Once i do it the 51st time the first one will be expired.

            So you can have a max of 50 out standing refresh tokens per user.

            Second issue: Google does not return a new refresh token to you with every authorization request for a user. (Don't ask me why. It appears to be language specific. C# and java get a new token back every time. PHP and Python don't appear to.) Google assumes that you have stored that refresh token. I think if you do prompt=consent in the requested it will force it to return to you a new one. You can also have the user revoke your access to their app though there google account this would also trigger a new consent and return an access token and refresh token.

            If prompt=consent doesn't work then go though this link and remove the apps access from your google account.

            Third issue: Refresh tokens and access tokens are not interchangeable. A refresh token is used to request a new access token. an access token is used to access an api.

            So by doing this



            PHPMailer: Working on localhost, stuck after clicking "submit" button on the domain, gives Error 503, E-Mail arrives after 4mins
            Asked 2022-Mar-13 at 12:21

            So I've been trying now for two days to get rid of this problem. As mentioned, the code works perfectly fine on my xampp apache localhost. The Email is send immediately. However, on the domain which I have, once I press submit, it just loads and loads, and after 5mins or so gets a timeout, or rather a "503 Servive unavailable". I've checked my local PHP error log, everything is fine. I don't have access to the error log on the server though.

            Here is the code for the form:



            Answered 2022-Mar-13 at 12:21

            I think that you should change SMTP port and SMTP Secure to:



            What is the purpose of the ob_ functions in php? (ob_start(), ob_get_contents(), etc.)
            Asked 2022-Mar-08 at 21:00

            I've read the PHP documentation, but it fails to give any practical examples.

            I'm using some open source code, and it contains this email function. I'm trying to understand why these ob_XXX() functions are here and what they do (because I need to use PHPMailer instead of mail()). When I print the return value before the return, it's always empty.



            Answered 2022-Mar-08 at 21:00

            If you say this in PHP:



            Hiding php codes from file_get_contents method
            Asked 2022-Feb-19 at 19:03

            I am sending email with PHPMailer. My email design is available in the template.php file. I am pulling the contents of the template.php file with the file_get_contents method in my mail.php file. But I have such a problem, all my php codes in the template.php file are also visible. How can I hide them?




            Answered 2022-Feb-19 at 17:50

            Don’t use file_get_contents for that, use include with output buffering. That way it will run the PHP code and you’ll see the results of its execution instead of the code itself.



            PHPMailer not working - no specific error
            Asked 2022-Feb-14 at 10:31

            I have an old website that was not created by me, I noticed that the contact form doesn't work and when you press send it doesn't do anything. In the console it says:

            POST path of the mailer file 500 (Internal Server Error)

            I can't find a solution so if anyone can help I would be very grateful. Here's the code:



            Answered 2022-Feb-14 at 10:12

            I added ini_set("display_errors", "On"); at the top of the file and mailer->SMTPDebug = 2; after $mailer = new PHPMailer(); then I looked at the error in the Network section of the browser toolbox. I found out that the error was in the line:



            How to force TLS 1.2 usage for PhpMailer 5.2
            Asked 2022-Feb-04 at 09:50

            Recently the 3rd party email service provider I was using made a change. They disabled support for TLS 1.0 and TLS 1.1.

            I provide support for an ancient system that still uses php 5.3 and phpmailer 5.2.

            My tests indicates that TLS 1.2 is enabled.

            But, the PHPMailer code cannot connect to the email server after the disabling of TLS 1.0 and 1.1

            Also, note that I am not a full time php expert.

            Is there a way to make PHPMailer 5.2 use tls 1.2?



            Answered 2021-Nov-07 at 14:47

            It's not up to PHPMailer, its up to the version of PHP that you're using to run it, so the solution is to update your PHP version. The major changes relating to TLS were largely in PHP 5.6, so upgrading to that would be a good intermediate point if you're really stuck with this legacy version.



            Composer post-install scripts not executed
            Asked 2022-Jan-21 at 09:47

            I am trying to build a docker image with a PHP application in it.

            This application installs some dependencies via composer.json and, after composer install, needs some customizations done (eg some files must be copied from vendor folder into other locations and so on).

            So I have written these steps as bash commands and putted in the composer.json post-install-cmd section.

            This is my composer.json (I've omitted details, but the structure is the same):



            Answered 2022-Jan-21 at 09:22

            Please have a look at the documentation of Composer scripts. It explains pretty obvious:

            post-install-cmd: occurs after the install command has been executed with a lock file present.

            If you are using composer install with a lock file not present (as indicated from the console output), this event is not fired.


            Community Discussions, Code Snippets contain sources that include Stack Exchange Network


            No vulnerabilities reported

            Install PHPMailer

            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:. 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.
            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!.


            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.
            Find more information at:

            Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items

            Find more libraries

            Stay Updated

            Subscribe to our newsletter for trending solutions and developer bootcamps

            Agree to Sign up and Terms & Conditions

            Share this Page

            share link

            Reuse Pre-built Kits with PHPMailer

            Consider Popular Email Libraries


            by PHPMailer


            by nodemailer


            by mjmlio


            by Foundry376


            by postalserver

            Try Top Libraries by PHPMailer


            by PHPMailerPHP