Archive

Archive for July, 2009

Using php mail(); and headers

July 16th, 2009 admin 1 comment

So today, I came across an interesting question today which never had come up before to me. The PHP mail(); function. It is such a seemingly simple function, but often misunderstood; largely because its format and raw mail syntax.

PHP mail(); does not offer a specific field for each and every possible mail option, but we’ll go into it later. We’ll go through the very basics, then start touching upon what I am alluding to (headers).

The basic syntax is: mail(TO,SUBJECT,MESSAGE,HEADERS).
I assume one can figure out what each of those are (provided that you speak English well).

Now, since the function itself is self-explanatory, we’re back to the reason for this article; headers. Headers are optional fields in a CLR format using \r\n line-breaks between each of the different types. A common header would be something like from. For clarity (and cleanliness), headers are usually stored in a variable, so let’s take a quick look at how one code make this work.

<?php
$headers = "From: your@email.com\r\n
CC: a.public@email.address.com\r\n
BCC: secret@user1.com,\r\nsecret@user2.com,\r\nand@so.on.com\r\n";

mail("someone@somewhere.com","Test e-mail!","Some message",$headers);
exit();
?>

The above code should thoroughly explain headers. There are many different fields one could put in there, but these are just a few. The above example includes a from address, a CC, and a BCC (with multiple addresses).

So overall, the php mail(); function is a simple, yet very useful tool for many users to use. A much better alternative to some forms, especially the last resort “mailto” link type.

Regards,
Dennis M.

Categories: PHP Tags:

Delayed Updates…

July 10th, 2009 admin No comments

In a new blog I will soon inform you on why the updates have been so delayed. I apologize for this, but the blog is STILL active. Content is simply slow at the moment, but again, in the next post I’ll inform everyone as to why.

Thanks for your understanding,
Dennis M.

Categories: News Tags: