|
Using PHP to send mails
|
|
07-23-2011, 04:03 PM
|
|||
|
|||
|
Using PHP to send mails
We all know that PHP is one of the most widely used web scripting languages. When we create websites or web-applications (whether using PHP or not), we at many times need to send emails. We may use mails to
Now, PHP has an inbuilt function called mail(). Let us discuss that. The PHP mail() function accepts 5 parameters. Please note that not all 5 parameters are mandatory. PHP Code: mail($to,$subject,$message,$headers,$parameters)
Now that we understand the mail() function. Let us see a simple example. PHP Code: // Set up parametersThats it ! Now, the example that we just saw sends only plain text as the body of the email. What if you want to send some HTML as well ?? It can be made possible, by adding a little bit more information in your email headers. PHP Code: // Set up parametersPlease note that, you have to separate headers by introducing a line break in between them. For windows system we use "\r\n" to introduce line breaks. For unix bases system we use "\n" to introduce line breaks. Isn't it easy ?? Limitations: (yes there are limitations!)
So what is the solution for this ? Use SMTP to send emails. We will see about it in a follow up post. But for now, lets enjoy the power and simplicity of the PHP mail() function. Please let me know if I have missed some point or if something is not clear. I hope you guys find this tutorial useful. . . Thank you freeVps and Loomhosts for the amazing VPS . . |
|||
|
07-23-2011, 04:17 PM
|
|||
|
|||
|
RE: Using PHP to send mails
Fantastic. Thanks for sharing.
Patience has a limit and if you choose to be patient beyond this limit then it causes anger.
|
|||
|
07-23-2011, 06:30 PM
|
|||
|
|||
|
RE: Using PHP to send mails
Whoa. Nice tutorial
|
|||
|
07-24-2011, 12:01 AM
|
|||
|
|||
|
RE: Using PHP to send mails
Most of the causes of emails being marked as spam are from the sending server being misconfigured, server being blacklisted or sending too much mail to one mail provider too fast.
|
|||
|
07-27-2011, 09:10 PM
|
|||
|
|||
|
RE: Using PHP to send mails
Good job the way it should look like when someone tries.
|
|||
|
« Next Oldest | Next Newest »
|
| User(s) browsing this thread: |
| 1 Guest(s) |








