The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Problem sending emails using Mail Mime

Discussion in 'E-mail Discussions' started by fyremoon, Jul 19, 2011.

  1. fyremoon

    fyremoon Registered

    Joined:
    Nov 28, 2009
    Messages:
    2
    Likes Received:
    0
    Trophy Points:
    1
    Hello,

    I wrote this script but it won't send, won't give an error message either:

    require_once "Mail.php";
    include('Mail/mime.php');
    $email="me@mydomain.com";
    $crlf = "\n";
    $hdrs = array(
    'From' => 'sender@hosteddomain.com',
    'Subject' => 'MySubject'
    );

    $mime = new Mail_mime(array('eol' => $crlf));
    $text="text";
    $mime->setTXTBody($text);
    $body = $mime->get();
    $hdrs = $mime->txtHeaders($hdrs);
    $mail =& Mail::factory('mail');
    $mail->send($email, $hdrs, $body);
    ?>

    But...
    <?php
    $to = "me@mydomain.com";
    $subject = "Hi!";
    $body = "Hi,\n\nHow are you?";
    if (mail($to, $subject, $body)) {
    echo("<p>Message successfully sent!</p>");
    } else {
    echo("<p>Message delivery failed...</p>");
    }
    ?>
    Works fine...

    I am running CentOS 5.5, WHM 11.30.1 build 4
    PHP 5.2.9 and Mail-1.2.0, Mail_Mime-1.8.1


    It works on my other server that doesn't run cPanel so there must be something obscure that is preventing it.

    Best,

    John
     
  2. fyremoon

    fyremoon Registered

    Joined:
    Nov 28, 2009
    Messages:
    2
    Likes Received:
    0
    Trophy Points:
    1
    Sorry,

    I've found the problem...

    The example I used to write the code from is wrong.

    $hdrs = $mime->txtHeaders($hdrs);

    should be:

    $hdrs = $mime->headers($hdrs);

    Best,

    John
     
Loading...

Share This Page