Results 1 to 1 of 1

Thread: PROBLEM: Sending emial using gmail server

  1. #1
    Slesher is offline New Member: Posts Will Be Moderated
    Join Date
    May 2011
    Posts
    1

    PROBLEM: Sending emial using gmail server

    Hello,

    For some time I was trying to create and send automatic email using php script and gmail server and I always get this error:
    Warning: mail() [function.mail]: Failed to connect to mailserver at "ssl://smtp.gmail.com" port 465, verify your "SMTP" and "smtp_port" setting in php.ini or use ini_set() in C:\xampp\php\PEAR\Mail.php on line 141

    Here is my code
    Code:
    require_once ("mail.php");
    ini_set("SMTP","ssl://smtp.gmail.com");
    ini_set("SMTP_PORT", 465);
    
                       $to = $sqlmail['email'];
                       $from = $fromemail['email'];
                       $body = "Hello, \n\n";
                       $body .= "This is a request to borrow the following book\n";
                       $body .= "Title: $title\n";
                       $body .= "Author: $author\n";
                       $body .= "Year: $year\n";
                       $body .= "From the user $_SESSION[username]\n";
                       $subject = $title . " " . $author . " " . $year;
                       
    
                       
                       $host = "ssl://smtp.gmail.com";
                       $port = "465";
                       $username = "slesher.gmail.com";
                       $password = "*******";
    
                       $headers = array ('From' => $from,
                                'To' => $to,
                                'Subject' => $subject);
                       $smtp = new Mail();
                       $smtp ->factory('smtp',
                       array ('host' => $host,
                             'port' => $port,
                             'auth' => true,
                             'username' => $username,
                             'password' => $password));
    
                       $mail = $smtp->send($to, $headers, $body);
    Any help would be greatly appreciated.
    Last edited by Slesher; 05 May 2011 at 02:39 PM.

Similar Threads

  1. Gmail in frames?
    By hah2110 in forum Web Design, HTML Reference and CSS
    Replies: 1
    Last Post: 26 Nov 2010, 02:18 PM
  2. Server issue or PHP? - Contact Form Not Sending HTML correctly?
    By Editor08 in forum Client & Server Side Scripting (PHP, ASP, JavaScript)
    Replies: 1
    Last Post: 03 Oct 2009, 04:37 PM
  3. Hello from seedsterster@gmail.com
    By shinjitsu in forum Tell Us About Yourself
    Replies: 0
    Last Post: 16 May 2006, 01:30 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •