How I Can Use PHP To "Post By Email"

  • Author
    Posts
  • #684352

    justanimal
    Member

    i want use “Post by Email” feature,but have some problems,my blog can’t reveive email!
    at first i use phpmailer,and here is the code:

    require_once(‘./class-phpmailer.php’);
    $mail = new PHPMailer(true); // the true param means it will throw exceptions on errors, which we need to catch
    $mail->IsSMTP(); // telling the class to use SMTP

    try {
    $mail->Host = “pop.gmail.com”; // SMTP server
    $mail->SMTPDebug = 2; // enables SMTP debug information (for testing)
    $mail->SMTPAuth = true; // enable SMTP authentication
    $mail->SMTPSecure = “ssl”; // sets the prefix to the servier
    $mail->Host = “smtp.gmail.com”; // sets GMAIL as the SMTP server
    $mail->Port = 465; // set the SMTP port for the GMAIL server
    $mail->Username = “(email redacted)”; // GMAIL username
    $mail->Password = “mypwd”; // GMAIL password

    // $mail->AddAddress(“(email redacted)”,”justanimal”);
    //$mail->AddBCC(“(email redacted)”,”justanimal”);
    $mail->AddAddress(“(email redacted)”,”xiehua”);
    //$mail->AddAddress(“(email redacted)”,”xiehua”);
    $mail->SetFrom(‘(email redacted)’,”xiehua”);
    $mail->AddReplyTo(‘(email redacted)’, ‘xiehua’);
    $mail->Subject = ‘hello’;
    $mail->MsgHTML(“[title hello] [tags hello,animals] helloworld”);
    $mail->Send();
    echo “Message Sent OK</p>\n”;
    } catch (phpmailerException $e) {
    echo $e->errorMessage(); //Pretty error messages from PHPMailer
    } catch (Exception $e) {
    echo $e->getMessage(); //Boring error messages from anything else!
    }

    i try
    1. send to my gmail and wordpress blog , blog can’t receive email
    2. send to my gmail and cc to wordpress blog, blog can’t receive email
    3. send to my gmail and bcc to wordpress blog, blog can’t receive email.
    4. send to wordpress blog, blog can’t receive email.

    and then i try mail() function. and i change the header,also can’t receive email
    code is here

    $headers .= “Date: “. date(“D, j M Y H:i:s”).”\n”; //date;
    $headers .= “From: <(email redacted)>\n”; // your mail
    $headers .= “To: \”blog\” <(email redacted)>\n”; // mail to post
    $headers .= “Content-Type: text/plain; charset=UTF8; format=flowed \n” ;

    $headers .= “Content-Transfer-Encoding: 8bit\n”;
    $param = “-f <(email redacted)>”; // your mail
    mail (“(email redacted)”, “this is a test” , “can you help me?”,$headers,$param);

    this also can’t receive email!
    but if i use gmail or outlook ,the wordpress blog can receive email!
    can you help me?
    Blog url: http://justanimal.wordpress.com/

    #684509

    justanimal
    Member

    i try the wp-mail can still failed

    error_reporting(E_ALL);
    require_once(dirname(__FILE__) . ‘/../../../wp-config.php’);
    require_once(ABSPATH.’/wp-admin/includes/taxonomy.php’);
    require_once(ABSPATH.’/wp-includes/pluggable.php’);

    nocache_headers();
    global $wpdb;
    $headers .= “Date: “. date(“D, j M Y H:i:s”).”\n”; //date;
    $headers .= “From: <(email redacted)>\n”; // your mail
    $headers .= “To: \”blog\” <(email redacted)>\n”; // mail to post
    $headers .= “Content-Type: text/plain; charset=UTF8; format=flowed \n” ; // you can change ISO-8859-1 to UTF8
    $headers .= “Content-Transfer-Encoding: 8bit\n”;
    $param = “-f <(email redacted)>”; // your mail
    wp_mail( “(email redacted)”, “this is a test”, “can you help me?”,$headers,$param);

    #684517

    justanimal
    Member

    my gmail can receive email,but wordpress blog can’t receive the email.i not sure whether wordpress have some limited?

    #684576

    macmanx
    Staff

    We filter out these sort of requests as they can easily be abused by spammers.

    The emails must come from an actually email or webmail client.

The topic ‘How I Can Use PHP To "Post By Email"’ is closed to new replies.