Solved

php smtp gmail

Posted on 2012-04-01
5
482 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

Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Question has a verified solution.

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

Suggested Solutions

Whether you’re a college noob or a soon-to-be pro, these tips are sure to help you in your journey to becoming a programming ninja and stand out from the crowd.
Are you irritated by repeating emails issue in Microsoft Outlook 2016 after recent update ?  Lets’ see how to resolve and prevent duplicate emails in the Outlook 2016 using some simple techniques.
This video teaches viewers about errors in exception handling.
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.

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