PHP mailer | mail() error

Discussion in 'PHP' started by coder 525, Jul 10, 2008.

  1. #1
    I am trying to use phpmailer. I am able to send mails to . But I could not send mails to any other --- yahoo or gmail ids.
    If I use simple mail() function, then also the same situation is there.
    worth2read.org is my domain name. In both cases, message sent is displayed.
    But the message is actually send only if it is .
    Any help please...

    <?php
    error_reporting(E_ALL);
    error_reporting(E_STRICT);
    include_once('class.phpmailer.php');
    $mail = new PHPMailer();
    $mail->IsSendmail(); // telling the class to use SendMail transport
    $mail->From = "reachme@worth2read.org";
    $mail->FromName = "Worth2read";
    $mail->Subject = "PHPMailer Test Subject via mail()";
    $body="checking";
    $mail->MsgHTML($body);
    $mail->AddAddress("admin@yahoo.com", "Gisha James");
    if(!$mail->Send()) {
    echo "Mailer Error: " . $mail->ErrorInfo;
    } else {
    echo "Message sent!";
    }
    ?>
     
    coder 525, Jul 10, 2008 IP
  2. serialCoder

    serialCoder Guest

    Best Answers:
    0
    #2
    its probably a sendmail or smtp error
     
    serialCoder, Jul 10, 2008 IP
  3. revvi

    revvi Peon

    Messages:
    58
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Hi,

    I use this class a lot in my programs. It can send to gmail/yahoo or others.
    The only tricky part is in certain server (your server) does not like FromName. And try to to test it by not using Name in the sender like this:

    <?php
    error_reporting(E_ALL);
    // error_reporting(E_STRICT);
    include_once('class.phpmailer.php');
    $mail = new PHPMailer();
    
    // use default mail first
    // $mail->IsSendmail(); // telling the class to use SendMail transport
    
    $mail->From = "reachme@worth2read.org";
    
    // test by commented the following line
    //$mail->FromName = "Worth2read";
    
    $mail->Subject = "PHPMailer Test Subject via mail()";
    $body="checking";
    
    // $mail->MsgHTML($body);
    $mail->Body = $body;
    $mail->IsHTML = true; // I forgot between IsHTML or IsHtml
    
    // try to use like this instead
    // $mail->AddAddress("admin@yahoo.com", "Gisha James");
    $mail->AddAddress("admin@yahoo.com");
    if(!$mail->Send()) {
    echo "Mailer Error: " . $mail->ErrorInfo;
    } else {
    echo "Message sent!";
    }
    ?>
    PHP:
     
    revvi, Jul 11, 2008 IP
  4. uzairjawed

    uzairjawed Active Member

    Messages:
    114
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    53
    #4
    uzairjawed, Jul 11, 2008 IP
  5. coder 525

    coder 525 Peon

    Messages:
    30
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Hi Revvi,
    I used ur code, still the same result..
    It is working for ( if the to address is ) and
    for no yahoo or gmail...
     
    coder 525, Jul 11, 2008 IP
  6. revvi

    revvi Peon

    Messages:
    58
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #6
    Probably there are some misconfiguration in your mail() or gmail/yahoo reject your domain.

    I tested in my server, it works fine (of course by changing From using the existing email address in my acc) and sending it to any gmail/yahoo.

    What kind of server do you have? Linux with cpanel?
     
    revvi, Jul 11, 2008 IP
  7. revvi

    revvi Peon

    Messages:
    58
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #7
    It might be there is a problem in your mail configuration. What kind hosting are you using?. There is a possibility that the hosting blocked all outgoing mails to other domain (due to spamming reason?). Or probably gmail/yahoo reject your domain.

    I advice try to test in different server environment like in www.000webhost.com. It is free one. Then try to get a free domain name from co.cc. If you need more info, try to msg me.
     
    revvi, Jul 11, 2008 IP
  8. coder 525

    coder 525 Peon

    Messages:
    30
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #8
    Yes Revvi, I am having Linux with cpanel. If I send a mail from (using outlook express) to my Yahoo id it is going...
    One doubt : After downloading phpmailer which all files need to be uploaded to the server. Because as u know there are many files associated with phpmailer(like examples, languages etc)
     
    coder 525, Jul 12, 2008 IP
  9. revvi

    revvi Peon

    Messages:
    58
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #9
    Hi again, please note the smtp server configuration in your outlook express. Try to use SMTP instead of default mail or SendMail.
    I forgot how to use IsSMTP in the phpmailer. But surely phpmailer can do smtp style one. Please have a look in the phpmailer documentation as I never use this technique (default mail is working fine for all my purposes).

    Please let me know the result.
     
    revvi, Jul 12, 2008 IP