the best way to send email is through smtp authentication. by doing this, you will avoid the emails you send are not going to go to the user's junk email section. for example, if you send it to some user who has yahoo email, it will be send to Spam sections. also i have another carrier, and they filter emails and any email that looks like spam or suspicious of spam goes to the MailGuard section.

so the best way is to send a your recipient a legitimate email is by using smtp authentication. many providers use this. if you dont, some websites like AOL will reject your email.

so how do you do it?

i use a very simple php script, this code/snippet i tested and it works well.

i will show you step by step tutorial guide ok.

1. open your text editor (like notepad)
2. copy and paste this code:

<?php
# THIS IS THE PHP PEAR CLASS USED FOR SENDING OUR EMAIL
require_once "Mail.php";
#########################################
############ CONFIGURATION ##############
#########################################
# SERVER SETTINGS
$host = "localhost";
$username = "[email protected]";
$password = "mypass123";
# SENDERS INFORMATION
$FromName = "wallpaperama";
$FromEmail = "[email protected]";
# RECIPIENT INFORMATION
$ToName = "my friend";
$ToEmail = "[email protected]";
# EMAIL TITLE
$subject = "Wallpaperama Email";
# EMAIL CONTENT
$body = "
Hinn
I'm sending this email using SMTP.nn
Thanks to Wallpaperama. Visit Wallpaperama.com for cool wallpapers
";
# STOP HERE !!!
#############################################################
$from = "$FromName<$FromEmail>"; // Provide your name and your email address
$to = "$ToName <$ToEmail>";
$headers = array ('From' => $from,
'To' => $to,
'Subject' => $subject);
$smtp = Mail::factory('smtp',
array ('host' => $host,
'auth' => true,
'username' => $username,
'password' => $password));
$mail = $smtp->send($to, $headers, $body);
if (PEAR::isError($mail)) {
echo("<p>" . $mail->getMessage() . "</p>");
}else{
echo("<p>Message successfully sent!</p>");
}
?>

3. Change the configurations setting according to your information. NOTE: you must have your username and password. usually, the hostname is will be localhost.

4. save the file as wallpaperama-smtp.php

5. upload the file to your php website and open it with your browser, if it works you will see a message that says: Message successfully sent! (look at the picture below, it worked for me)
20081003__smtp.jpg

6.next check the email to where you will be sending, you should see it. i sent it to my at&t email, and as you can see from the image below, i confirmed it works.
20081003__att-net-webmail.jpg


hope this helps you

NOTE: if for some reason you see this error:
Warning: require_once(Mail.php) [function.require-once]: failed to open stream: No such file or directory in /var/html/wallpaperama-smtp.php on line 3

Fatal error: require_once() [function.require]: Failed opening required 'Mail.php' (include_path='.:/usr/share/pear:/usr/share/php') in /var/html/wallpaperama-smtp.php on line 3


Be sure to install php pear Email package

this is how you install it:
yum install php-pear-Mail


after installation completed, restart your web server:
/etc/init.d/httpd restart


NOTE: i was using red hat fedora core 7 on my linux machine

also, you might get this error if you dont install the php pear mail:

fatal error class mail not found in index.php on line 17