Solved

php smtp gmail

Posted on 2012-04-01
5
448 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
Comment Utility
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
Comment Utility
thank you
0
 

Author Comment

by:pep477
Comment Utility
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
Comment Utility
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
Comment Utility
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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

Email attacks are the most efficient and effective way for cyber criminals and hackers to compromise a computer or network. We often find our-self second guessing the authenticity of an email message, for such instances we can follow practical princ…
Check out this infographic on what you need to make a good email signature that will work perfectly for your organization.
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.

772 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

16 Experts available now in Live!

Get 1:1 Help Now