Solved

php smtp gmail

Posted on 2012-04-01
5
467 Views
Last Modified: 2012-04-01
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
Comment
Question by:pep477
  • 3
  • 2
5 Comments
 
LVL 42

Accepted Solution

by:
sedgwick earned 500 total points
ID: 37793226
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
 

Author Closing Comment

by:pep477
ID: 37793364
thank you
0
 

Author Comment

by:pep477
ID: 37793791
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
 
LVL 42

Expert Comment

by:sedgwick
ID: 37794554
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
 
LVL 42

Expert Comment

by:sedgwick
ID: 37794558
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

This article covers general Notes 8.5 troubleshooting information including recreating the Notes\Data folder.
Resolve Outlook connectivity issues after moving mailbox to new Exchange 2016 server
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

895 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now