Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 549
  • Last Modified:

php smtp gmail

I need a working php smtp class that can log in to gmail smtp and send mails by it. I already have mail() working, but i want to send a lot of emails, so i want smtp gmail log in, anyone please help, if anyone have a already ready class to do this, i´ll be much greatiful
0
pep477
Asked:
pep477
  • 3
  • 2
1 Solution
 
Meir RivkinFull stack Software EngineerCommented:
here's a php snippet from http://stackoverflow.com/questions/712392/send-email-using-gmail-smtp-server-from-php-page:

<?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-->

Open in new window


also check this cool tutorial:
http://www.web-development-blog.com/archives/send-e-mail-messages-via-smtp-with-phpmailer-and-gmail/
0
 
pep477Author Commented:
thank you
0
 
pep477Author Commented:
I checked that gmail has a 500 mail/day limit. Can i in any way or any other smtp server get that limit higher? i heard that i can create multiple Gmail accounts and than check to see if reached the limit and go to the other account, but Gmail block just the account or they have a control by ip to?
0
 
Meir RivkinFull stack Software EngineerCommented:
Why did accept my post as a solution if you are not satisfied?
This is exactly what u asked for so why grade C?
0
 
Meir RivkinFull stack Software EngineerCommented:
And u still needs my help so wait with the points till you get what u want and only then decide how many points to award...
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now