IT Community - Software Programming, Web Development and Technical Support

How to Send Email from a PHP Script Using SMTP Authentication?

This is a discussion on How to Send Email from a PHP Script Using SMTP Authentication? within the PHP Programming forums, part of the Web Development category; How to Send Email from a PHP Script Using SMTP Authentication...


Go Back   IT Community - Software Programming, Web Development and Technical Support > Web Development > PHP Programming

Register FAQ Members List Calendar Mark Forums Read
  #1 (permalink)  
Old 07-18-2007, 12:45 AM
Sabari Sabari is offline
D-Web Genius
 
Join Date: Jul 2007
Posts: 1,008
Sabari is on a distinguished road
Exclamation How to Send Email from a PHP Script Using SMTP Authentication?

How to Send Email from a PHP Script Using SMTP Authentication
__________________
Thanks & Regards
Sabari...
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 07-20-2007, 05:42 AM
Senthilkumar Senthilkumar is offline
D-Web Programmer
 
Join Date: Mar 2007
Posts: 93
Senthilkumar is on a distinguished road
Default Re: How to Send Email from a PHP Script Using SMTP Authentication?

Send Email from a PHP Script Using SMTP Authentication[list][*]To connect to an outgoing SMTP server from a PHP script using SMTP authentication and send an email:
  • Make sure the PEAR Mail package is installed.
    • Typically, in particular with PHP 4 or later, this will have already been done for you. Just give it a try.
  • Adapt the example below for your needs. Make sure you change the following variables at least:
    • from: the email address from which you want the message to be sent.
    • to: the recipient's email address and name.
    • host: your outgoing SMTP server name.
    • username: the SMTP user name (typically the same as the user name used to retrieve mail).
    • password: the password for SMTP authentication.

Sending Mail from PHP Using SMTP Authentication Example

<?php
require_once "Mail.php";

$from = "Sandra Sender <sender@example.com>";
$to = "Ramona Recipient <recipient@example.com>";
$subject = "Hi!";
$body = "Hi,\n\nHow are you?";

$host = "mail.example.com";
$username = "smtp_username";
$password = "smtp_password";

$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>");
}
?>

Cheers
Senthil Kumar S
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to send email in VB.NET 2005(From Windows Applications) psivakumarmca81 VB.NET Programming 2 02-24-2008 07:20 PM
How to send email in VB.NET 2005(From Windows Applications) psivakumarmca81 Discussweb HQ 2 02-22-2008 08:33 PM
Email Send Using MYSQL or Oracle sivaramakrishnan Database Support 1 08-08-2007 03:39 AM
How to send variables from a PHP script to another URL, using POST without using form oxygen PHP Programming 1 07-26-2007 03:25 AM
How can I send variables from a PHP script to another URL using POST without using fo kingmaker PHP Programming 2 07-24-2007 02:58 AM


All times are GMT -7. The time now is 06:46 PM.


Copyright ©2004 - 2007, DiscussWeb. All Rights Reserved.

SEO by vBSEO 3.0.0