www.webdeveloper.com
Results 1 to 4 of 4

Thread: PHPMailer How to send mails to anyone ?

  1. #1
    Join Date
    Mar 2013
    Posts
    3

    Question PHPMailer How to send mails to anyone ?

    Hello,
    I am a beginner to PHP and Web 2.0 development in general. I am making a project in which where once a user sign's up he/she will get a confirmation email in his/her inbox and must confirm the mail id by clicking on a link. Pretty standard stuff. Now I am using the latest version of PHPMailer to do this. I am connected to the gmail smtp, and the settings are as follows-:

    Code:
    $mail->Host       = "smtp.gmail.com"; // SMTP server
    $mail->SMTPDebug  = 2;                     // enables SMTP debug information (for testing)
                                               // 1 = errors and messages
                                               // 2 = messages only
    $mail->SMTPAuth   = true;                  // enable SMTP authentication
    $mail->SMTPSecure = "tls";                 // sets the prefix to the servier
    $mail->Host       = "smtp.gmail.com";      // sets GMAIL as the SMTP server
    $mail->Port       = 587;                   // set the SMTP port for the GMAIL server
    $mail->Username   = "foobar@gmail.com";  // GMAIL username
    $mail->Password   = "foobar";            // GMAIL password
    Now when I am sending mails to a person who has a Gmail account it is working fine. But the moment I am sending any mail to someone with a Yahoo account, the mail doesn't seem to reach the client. Do I have to reconfigure PHPMailer again to say the yahoo SMTP service. Can I send mails to yahoo through the GMail SMTP ??? Or do i have to reconfigure again each time I have to send mail to a different service provider ?? Thank You.

  2. #2
    Join Date
    Aug 2004
    Location
    Ankh-Morpork
    Posts
    19,408
    Have you checked the spam folder on the target Yahoo email account? (And yes, the SMTP server should be able to send the email anywhere on the net.)
    "Please give us a simple answer, so that we don't have to think, because if we think, we might find answers that don't fit the way we want the world to be."
    ~ Terry Pratchett in Nation

    eBookworm.us

  3. #3
    Join Date
    Mar 2013
    Posts
    3
    Quote Originally Posted by NogDog View Post
    Have you checked the spam folder on the target Yahoo email account? (And yes, the SMTP server should be able to send the email anywhere on the net.)
    Yup Checked the spam folder. No mail has reached.

  4. #4
    Join Date
    Mar 2013
    Posts
    3

    Exclamation

    My entire PHPMailer mail setup is as follows-:
    Code:
    <?php
    require_once('mailer/class.phpmailer.php');
    //include("class.smtp.php"); // optional, gets called from within class.phpmailer.php if not already loaded
    
    $mail             = new PHPMailer();
    
    $body             = "<html><head></head><body>
    <strong>This is a System generated message. PLEASE DO NOT REPLY TO THIS MAIL.</strong>
    <br />
    Click on the following ling to activate your account-:
    <br />
    <a href='http://www.google.co.in'>Click Here !! </a>
    <br />
    END OF MESSAGE.
    </body></html>";
    //$body             = preg_replace("[\]i",'',$body);
    
    $mail->IsSMTP(); // telling the class to use SMTP
    $mail->Host       = "smtp.gmail.com"; // SMTP server
    $mail->SMTPDebug  = 2;                     // enables SMTP debug information (for testing)
                                               // 1 = errors and messages
                                               // 2 = messages only
    $mail->SMTPAuth   = true;                  // enable SMTP authentication
    $mail->SMTPSecure = "tls";                 // sets the prefix to the servier
    $mail->Host       = "smtp.gmail.com";      // sets GMAIL as the SMTP server
    $mail->Port       = 587;                   // set the SMTP port for the GMAIL server
    $mail->Username   = "foobar@gmail.com";  // GMAIL username
    $mail->Password   = "foobar";            // GMAIL password
    
    $mail->SetFrom("iembcarocks@gmail.com", "India Indigenous");
    
    $mail->AddReplyTo("iembcarocks@gmail.com", "India Indigenous");
    
    $mail->Subject    = "India Indigenous Account Activation";
    
    $mail->AltBody    = "To view the message, please use an HTML compatible email viewer!"; // optional, comment out and test
    
    $mail->MsgHTML($body);
    
    $address = "alexde989@yahoo.com";
    $mail->AddAddress($address);
    
    if(!$mail->Send()) {
      echo "Mailer Error: " . $mail->ErrorInfo;
    } else {
      echo "Message sent!";
    }
        
    
    ?>
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <title>domail</title>
    </head>
    
    <body>
    </body>
    </html>
    The above configuration works fine for Gmail mails but I can't send mails to Yahoo. Do I have to change the "$mail->Host " parameter to the Yahoo SMTP ?? It is set to Gmail SMTP.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles