Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. Linux, Apache, MySQL, PHP
  4. How can I send e-mail with gmail account

How can I send e-mail with gmail account

Scheduled Pinned Locked Moved Linux, Apache, MySQL, PHP
helpquestion
4 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • H Offline
    H Offline
    hande54
    wrote on last edited by
    #1

    I need to send email with gmail account. I tried mail() function but it does not work. Could you help e on this issue? any recommendations are really appreciated :)

    M 2 Replies Last reply
    0
    • H hande54

      I need to send email with gmail account. I tried mail() function but it does not work. Could you help e on this issue? any recommendations are really appreciated :)

      M Offline
      M Offline
      Marc Firth
      wrote on last edited by
      #2

      you need to set: ini_set(sendmail_from, "youremail@gmail.com"); ini_set(SMTP, "smtpMailServerAddressGoesHere@gmail.com"); ini_set(smtp_port, 25); But I'm not sure what the correct values are.

      Portfolio | Web Design, Web Hosting & IT Support

      1 Reply Last reply
      0
      • H hande54

        I need to send email with gmail account. I tried mail() function but it does not work. Could you help e on this issue? any recommendations are really appreciated :)

        M Offline
        M Offline
        Marc Firth
        wrote on last edited by
        #3

        using pear:

        <?php
        require_once "Mail.php";

        $from = "Sandra Sender ";
        $to = "Ramona Recipient ";
        $subject = "Hi!";
        $body = "Hi,\n\nHow are you?";

        // stick your GMAIL SMTP info here! ------------------------------
        $host = "mail.example.com";
        $username = "smtp_username";
        $password = "smtp_password";
        // --------------------------------------------------------------

        $headers = array ('From' => $from,
        'To' => $to,
        'Subject' => $subject);
        $smtp = Mail::factory('smtp',
        array ('host' => $host,
        'auth' => true,
        'username' => $username,
        'password' => $password));

        $mail = $smtp->send($to, $headers, $body);

        if (PEAR::isError($mail)) {
        echo("

        " . $mail->getMessage() . "

        ");
        } else {
        echo("

        Message successfully sent!

        ");
        }
        ?>

        from about.com

        Portfolio | Web Design, Web Hosting & IT Support

        H 1 Reply Last reply
        0
        • M Marc Firth

          using pear:

          <?php
          require_once "Mail.php";

          $from = "Sandra Sender ";
          $to = "Ramona Recipient ";
          $subject = "Hi!";
          $body = "Hi,\n\nHow are you?";

          // stick your GMAIL SMTP info here! ------------------------------
          $host = "mail.example.com";
          $username = "smtp_username";
          $password = "smtp_password";
          // --------------------------------------------------------------

          $headers = array ('From' => $from,
          'To' => $to,
          'Subject' => $subject);
          $smtp = Mail::factory('smtp',
          array ('host' => $host,
          'auth' => true,
          'username' => $username,
          'password' => $password));

          $mail = $smtp->send($to, $headers, $body);

          if (PEAR::isError($mail)) {
          echo("

          " . $mail->getMessage() . "

          ");
          } else {
          echo("

          Message successfully sent!

          ");
          }
          ?>

          from about.com

          Portfolio | Web Design, Web Hosting & IT Support

          H Offline
          H Offline
          hande54
          wrote on last edited by
          #4

          thanks for your attention I will try it :)

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups