PHP mail() - send email with php

Sending email with php is very simple, few lines of code and it works.
You need to send email using php when you have a comment or contact us form, where your visitors contact you via a web page form, and you get the message to your email address, or when you have a signup / registration form and you want to send automatically a confirmation link or a welcome message to your new users.

This is how you send email using php:
$TO = "";
$h  = "From:";
$message = "my message here";
mail($TO, $subject, $message, $h);

That's it ! mail() function have 3 required parameters and one optional.
$To is the receiver email address, $subject is the subject and $message is the body of your message.
$h is optional, is the header you will send, it contains the sender email address ("FROM:")

I will post next how to send a html email, and how to use SMTP Authentication which means how to choose the smtp server and use your username and password to use that server.


rize wordpress said...

The Lamp Development platform may vary, depending upon the web programming language or operating system, used in it.

WT Labs said...

You tried something new!! Good for you! I’m always afraid I’ll mess up when I try new stuff. What made you decide to try something new? I’d like to get motivated. Maybe you have some ideas you can share. Java training jalandhar

mary Brown said...

I have read your blog its very attractive and impressive. I like it your blog.

PHP Training in chennai | PHP Training Course

PHP Training in chennai | Online PHP Course

Mary J. Smith said...

How to find and choose the best sports betting guide - OddsDigger. Click here for more details.