Php mail check server

PHP check if mail() function is enabled on your server

To check if mail function is enabled on your apache server you can try one of the following:

Check your php.ini like this:

You should search for this in the list sendmail_path that has the default value / usr / sbin / sendmail — t — i

You can also try to manual set it to this value by changing the php.ini file. To do this go to / etc / php5 / apache2 / php . ini and uncomment the sendmail_path line like this

If it did not work for you, try to find out if the function exists in the first place.

Читайте также:  Css фоновое изображение кнопки

And finally you can test what the php mail() function returns.

But more important than this is if the email arrives to your inbox (or Spam folder).

I have also find myself in need to check the mail function a WordPress platform. You can do this on WordPress by installing Check Email plugin. Although it has not been updated lately it still works and it does the job that it was installed for.

check mail

Like I said, a positive result does not mean that the email will be received. There are much more things to check here.

Hope this helped you. If not please let me know how you finally solve it.

Leave a Reply Cancel reply

Recent Posts

How to embed video into a website – Ultimate tutorial Embedding a video into HTML website seems an easy task, but there really are lots of aspects to. PrettyPhoto Minimal Theme – a pure CSS prettyPhoto simple theme I have recently used prettyPhoto for a project and I have to admit that it is a great tool to have. AJAX POST request: Invalid request (Malformed HTTP request) on console and net::ERR_EMPTY_RESPONSE on chrome dev tools When you encounter the error «Invalid request (Malformed HTTP request)» in the console and. Using preg_split() to explode() by multiple delimiters in PHP Just a quick note here. To [crayon-64ba8948e6805589384245-i/] a string using multiple delimiters. How to use PHP to insert content after or before HTML tag The problem is quite simple. you just want to count a specific tag on a page and insert some. Simple OAuth2 authorization code grant example using PHP and cURL The authorization code grant methods, should be very familiar if you’ve ever signed into an. Limit the number of keywords in WordPress tag cloud to control PageRank Did you know that the default wordpress tags, labels or keywords from the sidebar can have a huge. URL vs. URI vs. URN, What’s the difference / examples What is URI A URI identifies a resource either by location, or a name, or both. More often than. Build your own WordPress Twenty Sixteen Child Theme Child themes are very popular these days. We will create a simple child theme for the Twenty. Create a modal window using pure HTML5 and CSS3 In this tutorial we will create a modal window using only HTML5 and CSS3 properties. The techniques. Remove admin bar wordpress backend and frontend So, as mentioned above, supposedly the new Toolbar is meant to be impossible to remove. The reason. 7 years Google Adsense earnings statistics and 10.000$ barrier reached If you are on this page, there are lots of chances you have a Google Adsense account, you are. PHP logical operators true false The [crayon-64ba8948eaf7e874475096-i/] and [crayon-64ba8948eaf84004751809-i/] logical operators.

Источник

How to Test and Fix the php mail() Function

The php mail() function allows you to send emails directly from a php script.
This tutorial shows you how to test if php mail is working correctly.

Test php mail() on your Web Server

1. Create a php test file using a text editor and save it e.g. as test.php:

$sender = ‘ someone@somedomain.tld ‘;
$recipient = ‘ you@yourdomain.tld’ ;

$subject = «php mail test»;
$message = «php test message»;
$headers = ‘From:’ . $sender;

if (mail($recipient, $subject, $message, $headers))
echo «Message accepted»;
>
else
echo «Error: Message not accepted»;
>
?>

2. Change the $sender and $recipient in the code.

3. Upload the php file to your webserver.

4. Open the uploaded php file in your browser to execute the php script.

5. The output show either «Message accepted» or «Error: Message not accepted».

chevron_right Message accepted:

Open your mail client to see if the message was delivered to the specified email address.
(also check your spam folder!)

If the message was delivered:

If the message was not delivered:

  • Some provider don’t allow external recipients when using php mail. Change the recipient ($recipient) in the code to a local recipient. This means use an email address from the server’s domain, for example if your server domain is www.yourdomain.tld then the recipient’s email should be someone@yourdomain.tld.
  • Upload the modified php file and retry.
  • If it’s still not working: change the sender ($sender) to a local email (use the same email as used for recipient).
  • Upload the modified php file and retry.
  • Contact your provider if it still does not work.
    Tell your provider that the standard php «mail()» function returns TRUE, but not mail will be sent.
    It’s recommended to include the used php test script to show your provider, that the problem is not caused by the php script used.

chevron_right Error: Message not accepted

php mail might not be enabled:

  • Login to your webserver configuration and check the php settings.
    Some php installations require that you setup a default sender in the php configuration first.

Some provider don’t allow external recipients when using php mail:

  • Change the recipient ($recipient) in the code to a local recipient. This means use an email address from the server’s domain, for example if your server domain is www.yourdomain.tld then the recipient’s email should be someone@yourdomain.tld.
  • Upload the modified php file and retry.
  • If it’s still not working: change the sender ($sender) to a local email (use the same email as used for recipient).
  • Upload the modified php file and retry.

If you have checked the php settings, tried a local recipient and it’s still not working:

  • Contact your provider if you are unable to enable php mail().
    Tell your provider that the standard php «mail()» function returns FALSE.
    It’s recommended to include the used php test script to show your provider, that the problem is not caused by the php script used.

Disclaimer: The information on this page is provided «as is» without warranty of any kind. Further, Arclab Software OHG does not warrant, guarantee, or make any representations regarding the use, or the results of use, in terms of correctness, accuracy, reliability, currentness, or otherwise. See: License Agreement

  • ©1997-2023 Arclab®. All other trademarks and brand names are the property of their respective owners.
  • info_outline
  • fingerprint Cookies & Privacy

Источник

PHP Mail Not Working Not Sending (How To Fix It!)

After spending some time setting up your web server and writing up the scripts, the PHP mail function is not sending emails out as expected. Tutorials from all over the Internet show different solutions, and just what the heck is happening!? How do we fix it?

PHP mail requires a mail delivery server (SMTP) to send out emails, and there are 2 possible solutions:

  1. Install a local SMTP server.
    • Windows – Use Papercut for local testing.
    • Linux – Use sendmail or postfix, sudo apt-get install postfix .
  2. Use a remote SMTP server, simply point the SMTP settings in the php.ini file to the mail server.

That is the gist of it, but let us go through the actual steps on fixing the mail problem – Read on!

TLDR – QUICK SLIDES

Fix Mail Not Working Not Sending In PHP

TABLE OF CONTENTS

INSTALLING A LOCAL SMTP SERVER

All right, let us get started with the first solution – Installing a mail server on your own machine.

WINDOWS USERS – PAPERCUT SMTP FOR LOCAL TESTING

For Windows users, try out Papercut SMTP. Papercut is probably the fastest and fuss-free SMTP server for testing. While it can be configured to relay email out, I don’t really recommend using this for a production server.

LINUX USERS – POSTFIX OR SENDMAIL

For you guys who are on Linux, simply install Sendmail or Postfix –

sudo apt-get install postfix

But different flavors of Linux has a different package manager – YUM or RPM , just use whichever is correct.

UPDATE THE PHP.INI FILE

[mail function] SMTP=localhost smtp_port=25 ; For Win32 only. sendmail_from = doge@codeboxx.com

Finally in the php.ini file, simply ensure that SMTP is pointing to localhost . Also for the Windows users, set sendmail_from or you will get a “bad message return path” error message.

OTHER MAIL SERVERS – FOR PRODUCTION SERVERS

USING A REMOTE SMTP SERVER

Don’t want to install anything? Then use an existing SMTP server that you have access to.

POINT PHP.INI TO THE SMTP SERVER

To use an existing SMTP server, just update the php.ini file and point to the SMTP server accordingly. For example, we can actually point to the Gmail SMTP server:

[mail function] SMTP=smtp.gmail.com smtp_port=587 auth_username=YOUR-ID@gmail.com auth_password=YOUR-PASSWORD

That’s it, but I will not recommend using your personal Gmail, Yahoo, or Outlook accounts on production servers… At least use one of their business accounts.

EXTRA – GMAIL AUTHENTICATION

Is Google rejecting the SMTP requests? Authentication failure? That is because Google will simply not allow any Tom, Dick, and Harry to access your email account. Thankfully, we only need to do some security setting stuff to get past this issue.

ENABLE 2-STEP AUTHENTICATION

Firstly, enable the 2-step authentication on your Google account if you have not already done so. That is basically, sending a PIN code to your mobile phone when Google detects login from an unknown device.

CREATE AN APP PASSWORD

But of course, we are not going to answer a PIN code challenge whenever we try to send an email from the server… So what we are going to do instead, is to create an app password.

Select “Other (Custom Name)” under the drop-down menu.

You can name it whatever you want…

DONE!

Finally, just copy that email/password into php.ini .

EXTRA BITS

That’s all for the tutorial, and here is a small section on some extras that may be useful to you.

PHP MAIL DEBUGGING

  1. In your PHP script, check the error message after sending out the email – if (!mail(TO, SUBJECT, MESSAGE)) < print_r(error_get_last()); >
  2. Set mail.log = FOLDER/mail.log in php.ini .
  3. Also, set a mail log on the SMTP server itself.

That’s all. Do a test mail send and trace the log files – Did PHP send out the email? Did the SMTP server send out the email? Are the configurations correct? Lastly, also very important – Did you send it to the correct email address, is it even a valid email?

TONE DOWN FIREWALLS, ANTI-VIRUS, CHECK SPAM FOLDER

  • Windows – Check and allow an exception in the Windows firewall.
  • Linux – Allow an exception in iptables .
  • Elsewhere – Maybe a hardware firewall that is somewhere in the network, or an anti-virus stopping the SMTP send.

INFOGRAPHIC CHEAT SHEET

THE END

Thank you for reading, and we have come to the end of this guide. I hope that it has helped to solve your email problems, and if you have anything to share with this guide, please feel free to comment below. Good luck and happy coding!

Источник

How to check if mail() PHP function is enabled in your server

test-mail-function-adobe-muse

Usually, you will need mail() PHP function working in your server for advanced features in your Adobe Muse websites (like contact forms).

Best option to know if mail() PHP function is enabled in your server is contacting your hosting support.

Anyway, if you have some coding knowledge, you can test it yourself. It’s easy!

Use this code and change $from and $to values located inside double quotes.

  • $from usually will be the sender address which uses same domain as your website. Example: noreply@responsive-muse.com
  • $to will be the receiver address. This can be any email address, but be careful, sometimes free providers like GMail or Hotmail can send your emails to spam folder.

How to test it:

  1. You can test what the mail() PHP function returns by copying this code and saving it in a new empty text file as testmail.php“.
  2. Edit $to and $from emails. Be careful, do not delete anything outside double quotes or you will break the code.
  3. Upload testmail.php into your root FTP folder and visit it using your browser. So if your website is https://responsive-muse.com, you will upload testmail.php to root FTP folder and visit https://responsive-muse.com/testmail.php with your browser.
  4. When visiting testmail.php you should wait some seconds and you will see a message: “Message successfully sent” or “Message delivery failed“.
    1. If you see “Message successfully sent“, check destination address and look if the email arrives to your inbox or spam folder.
    2. If you see “Message delivery failed”, you should notify this to your provider.
    3. If you see any other thing (like weird messages or errors) probably you have broken testmail.php file when editing it. Some text editors in Mac or Windows may break the code. You should use professional text editors like Sublime Text or Notepad++.

    Источник

Оцените статью