PHP uses mail() to send emails

WBOY
Release: 2016-07-25 08:42:44
Original
889 people have browsed it

Previously we provided a PHP code snippet on how to send an email using Mandrill, but if you don’t want to use a third-party service, you can use the PHP code snippet below.

  1. function send_mail($to,$subject,$body)
  2. {
  3. $headers = "From: KOONKrn";
  4. $headers .= "Reply-To: blog@koonk.comrn";
  5. $headers . = "Return-Path: blog@koonk.comrn";
  6. $headers .= "X-Mailer: PHP5n";
  7. $headers .= 'MIME-Version: 1.0' . "n";
  8. $headers .= 'Content -type: text/html; charset=iso-8859-1' . "rn";
  9. mail($to,$subject,$body,$headers);
  10. }
Copy code

Usage:

  1. $to = "admin@koonk.com";
  2. $subject = "This is a test mail";
  3. $body = "Hello World!";
  4. send_mail($ to,$subject,$body);
  5. ?>
Copy code

Send email, PHP, mail


Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template