View Single Post
  #1  
Old 31st May 2011, 11:09
turktiger turktiger is offline
Senior Member
 
Join Date: Jan 2011
Turkey
Posts: 20
Question Send Mail from PHP Using SMTP Authentication
When i use smtp settings in tsse 5.6 mail go through spam folder of users is there any way to change tsse smtp settings with smtp authhentication and ssl encrption here are example codes for this ;

i want to send emails via hotmail , yahoo , gmail account

Code:
<?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 = "ssl://mail.example.com";
 $port = "465";
 $username = "smtp_username";
 $password = "smtp_password";
 
 $headers = array ('From' => $from,
   'To' => $to,
   'Subject' => $subject);
 $smtp = Mail::factory('smtp',
   array ('host' => $host,
     'port' => $port,
     '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>");
  }
 ?>

Last edited by turktiger; 31st May 2011 at 12:28.
Reply With Quote