Skip to content

Instantly share code, notes, and snippets.

@mansouryaacoubi
Last active January 8, 2019 14:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mansouryaacoubi/e0bcff5d7d36f83d3bc36c1f9cf9a163 to your computer and use it in GitHub Desktop.
Save mansouryaacoubi/e0bcff5d7d36f83d3bc36c1f9cf9a163 to your computer and use it in GitHub Desktop.
Send Mails in PHP using the settings in the INI file
<?php
require_once "SimpleMail.php";
SimpleMail::send("test@example.com", "This is the subject", "And this is the <b>body</b> of the mail");
<?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