PHP - How i can send email without using SMTP??

Asked By Devil Scorpio on 21-Feb-11 05:39 AM
Hi All,

It is very easy to send email through SMTP in my website.

So I want some alternate method to send email without using SMTP.

Can you please suggest some way to acheive above mentioned.

Thanks in advance.
Reena Jain replied to Devil Scorpio on 21-Feb-11 05:48 AM
hi,

you can use gmail account for this. here is the code sample for you

<?php
 
     require_once "Mail.php";
 
    $from = "<from.gmail.com>";
    $to = "<to.yahoo.com>";
    $subject = "Hi!";
    $body = "Hi,\n\nHow are you?";
 
    $host = "ssl://smtp.gmail.com";
    $port = "465";
    $username = "<myaccount.gmail.com>";
    $password = "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>");
     }
 
  ?>  <!-- end of php tag-->

hope this will help you
Santhosh N replied to Devil Scorpio on 21-Feb-11 05:49 AM
try with fsockopen() function as mentioned here..
http://php.bigresource.com/Track/php-zA1J6ulE/
Devil Scorpio replied to Santhosh N on 21-Feb-11 05:55 AM
Hi Santhosh,

I dont want to send email through SMTP.

Devil Scorpio replied to Reena Jain on 21-Feb-11 05:57 AM
Hi Reena,

How I can use this PHP script in HTML code??