Sun, January 24, 2021
 
https://devcodepro.comdevcodepro
Home · Latest · Trends  /  PHP
14

Check if php mail function is enabled

How to check if mail function is enabled on your server
<?php 
$headers = 'From: [email protected]' . "\r\n" . 'Reply-To: [email protected]' . "\r\n" . 'X-Mailer: PHP/' . phpversion();
$to  = '[email protected]';
$subject = 'Email Subject';
$text = 'Test email body';
if (mail($to, $subject, $text, $headers)) {
echo "Test php mail sent successfully";
} else {
echo"Message delivery failed";
}
?>
rated 14 times (14) (0)
comments: 0 / hits: 2400  / 4 years ago, tue, sep 6, 16, 10:42:24
More From » PHP
 

Comments

There are no comments for this Snippet yet
Only authorized users can post. Please sign in first, or register a free account
 
Share
Posted
Ronald
Member since Sep 6, 2016
Total Code Snippets: 22
Total Comments: 1
Location: New Britain, Connecticut
Ronald snippets
4 years ago, tue, sep 6, 16, 10:11:38
comments: 0 / hits: 2227
PHP
4 years ago, tue, sep 6, 16, 10:18:23
comments: 0 / hits: 2138
PHP
4 years ago, fri, sep 16, 16, 1:10:12
comments: 0 / hits: 2633
PHP
4 years ago, fri, sep 16, 16, 1:12:32
comments: 0 / hits: 1931
CSS
4 years ago, fri, sep 16, 16, 1:27:33
comments: 0 / hits: 2896
PHP
4 years ago, sun, sep 25, 16, 2:52:42
comments: 1 / hits: 2297
4 years ago, thu, nov 10, 16, 4:21:59
comments: 1 / hits: 2373
PHP
4 years ago, mon, nov 21, 16, 10:48:23
comments: 2 / hits: 6730
PHP
4 years ago, sun, dec 25, 16, 2:44:24
comments: 0 / hits: 4306