PHP Mail authentication

Please use the PHP Pear mail authentication, this is to prevent spammer to access the php normal mail() function which is insecure.

Please download the package on http://pear.php.net/package/Mail and then copy it to your working folder on the webserver. After that you have to include the files on your PHP. Please refer to this for more reference.
http://www.cyberciti.biz/tips/howto-php-send-email-via-smtp-authentication.html

This is the sample code

include("Mail.php");
/* mail setup recipients, subject etc */
$recipients = "feedback@yourdot.com";
$headers["From"] = "user@somewhere.com";
$headers["To"] = "feedback@yourdot.com";
$headers["Subject"] = "User feedback";
$mailmsg = "Hello, This is a test.";
/* SMTP server name, port, user/passwd */
$smtpinfo["host"] = "smtp.mycorp.com";
$smtpinfo["port"] = "25";
$smtpinfo["auth"] = true;
$smtpinfo["username"] = "smtpusername";
$smtpinfo["password"] = "smtpPassword";
/* Create the mail object using the Mail::factory method */
$mail_object =& Mail::factory("smtp", $smtpinfo);
/* Ok send mail */
$mail_object->send($recipients, $headers, $mailmsg);
?>

  • 23 Users Found This Useful
Was this answer helpful?

Related Articles

I get an error 'Server.CreateObject Failed' when I try to use CDONTs. What can I do?

CDONTs is no longer supported on Windows 2003 server.  Microsoft introduced CDO back several...

Do you allow custom COM components?

Yes, we do allow Custom Components and we have to charge setup fee for your COM Components...

ASP to MSSQL connection

Before you can access your MS-SQL Server database from your ASP code , you need to connect to it...

How do I send email from ASP using SMTP Authentication?

Please note that our mail server is configured with Authentication. Below is the code snippet...

After I configure the custom error setting in the control panel, I still get the generic error page?

Custom error setting is a web server setting that sets your website Error Pages, but you can...