Last active
January 8, 2019 14:02
-
-
Save mansouryaacoubi/e0bcff5d7d36f83d3bc36c1f9cf9a163 to your computer and use it in GitHub Desktop.
Send Mails in PHP using the settings in the INI file
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
require_once "SimpleMail.php"; | |
SimpleMail::send("test@example.com", "This is the subject", "And this is the <b>body</b> of the mail"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class SimpleMail { | |
public static function send($to, $subject, $message) | |
{ | |
if( is_array($to) ) $to = implode(', ', $to); | |
$from = 'Max Mustermann <max@mustermann.com>'; | |
$noreply = 'noreply@mustermann.com'; | |
// To send HTML mail, the Content-type header must be set | |
$headers = "MIME-Version: 1.0" . PHP_EOL; | |
$headers .= "Content-type: text/html; charset=iso-8859-1" . PHP_EOL; | |
// Additional headers | |
$headers .= "From: $from" . PHP_EOL . | |
"Reply-To: $noreply" . PHP_EOL . | |
'X-Mailer: PHP/' . phpversion(); | |
return mail($to, $subject, $message, $headers); | |
} | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment