Sep
22
2008
0

More elaboration on ’signed-by’ and ‘mailed-by’

A friend of mine, Tim recently asked me about the mail function in PHP programming which I wrote on how to edit or remove the default ’signed-by’ or ‘mailed-by’ label during the sending activity.

His question is, where to put the code? As far as I’m concerned, I was not talking about the code, or even code positioning.

I’m talking about a particular technique that we would use in order to edit or to remove the distracting label when we use mail() function in our code (programming).

The real situation yet to be explained
The default value for the labels is usually the domain name of the server hosting company we run from.

In example, let say you use a web hosting from the well-known BlueHost company. Then you planned to send mass email to your friends about your new site, without revealing your friends’ details among them.

So all you need to do is having your list in a database, and then use loop function to send mail to them, one by one, using the php mail() function. Perhaps, you’ll use a fake email, or your self-hosted email, or even your true email from Google mail or Yahoo! mail.

Unfortunately, when using this method, recipients will see the header (if they checked on it) of the email, stated that the mail you sent was mailed by (in example) mailserver#.bluehost.com.

This is what we don’t like to see. It’ll tell the recipients what hosting service we are using.

So, in order to remove or edit the default value, we need to do those things that I explained earlier. To see the post, click here.

I hope my friend Tim will get what I was actually saying. What say you?

Written by Coder in: function, mail, mailed-by, php, signed-by |
Sep
20
2008
6

Edit or remove ’signed-by’ or ‘mailed-by’

Recently I was trying to remove the labels ’signed-by’ or ‘mailed-by’ which displayed the server name of my web hosting company when I do mailing activities from PHP script.

I was actually wanted to have my domain or perhaps my ‘fake’ domain address to be there. I don’t want to display the web hosting company.

The labels are like distracting me as a mailer, because I don’t really need that to be displayed. They’re like disturbing my privacy.

After having some research, I finally found the answer. There’s actually five arguments in the mail() function, instead of just four like this:

mail($mailto,$subject,$message,$header);

The fifth argument is the answer to my question. I believe some of you might get in the same situation.

So lets get straight to the point. Choose one of these below:

  1. You want your domain to be displayed; or
  2. You want nothing to be displayed.

You can’t have them to display other than that. I.e: You want it to display ’signed-by: google.com’ or ‘mailed-by: yahoo.com’. No you can’t have it. Just choose one of the stated above.

If you want the first choice, do this:

  1. Create an email address from your domain, or take one you’ve had, like admin@yourdomain.com.
  2. Set your code like this:
    mail($mailto,$subject,$message,$header,’-f admin@yourdomain.com’);
  3. There’s no number 3, you’re done!

If you want the second choice, you only have to do the second one in the first choice. You may change the ‘admin@yourdomain.com’ to any email you’d like, i.e: myself@yahoo.com.

Easy, huh?

Written by Coder in: function, mail, mailed-by, php, signed-by |
Oct
18
2007
2

Save Time on Submitting Forms

I always involved in making applications that submit forms to databases. In order to save time, I just copy this function to all my applications – because they’re a great time saving function that suits all my applications. Here I’ll show you step by step on how I made the function:

(This is the form example)

<form method=”post” action=”/process”>
Input 1: <input type=”text” name=”input1″>
Input 2: <input type=”text” name=”input2″>
Input 3: <input type=”text” name=”input3″>
<input type=”hidden” name=”action” value=”submitForm1″>
<input type=”submit” value=”Submit”>
</form>

Note two important things in the form above:

  1. action value; and
  2. form action

The action value will ensure the form to be submitted the right way whereas the form action will lead itself to index.php.

In the index.php, I set a condition – switch ( portion(1) ) case "process";.

The "process" condition goes like this:

<?php
if ( isset($_POST['action']) && $_POST['action'] == “submitForm1″ ) {
  if ( submitForm($_POST) ) echo “Successful!”;
  else echo “Failed!”;
}
?>

Do you realize – I sent the data using array – $_POST array! This is what I’m talking about. Sorry for the long intro… :P

Ok now let’s see what is inside the submitForm() function. In brief, the function must contain:

  1. key assigning process for each input value;
  2. character control using str_replace function;
  3. additional controls and conditions; and
  4. SQL statement structures;

I set the head like this:

function submitForm($post,$additional_input=”,$unwanted_input=”)

Now we’ve covered the main concept and some code go through. I think I’ve to stop here for now. See you in Part II!

Written by Coder in: php |

Powered by WordPress. Theme: TheBuckmaker. Download PHP Scripts, Wasserbelebung website stats