How I Can Use PHP To "Post By Email"
-
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 SMTPtry {
$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 visible only to moderators and staff)”; // GMAIL username
$mail->Password = “mypwd”; // GMAIL password// $mail->AddAddress(“(email visible only to moderators and staff)”,”justanimal”);
//$mail->AddBCC(“(email visible only to moderators and staff)”,”justanimal”);
$mail->AddAddress(“(email visible only to moderators and staff)”,”xiehua”);
//$mail->AddAddress(“(email visible only to moderators and staff)”,”xiehua”);
$mail->SetFrom(‘(email visible only to moderators and staff)’,”xiehua”);
$mail->AddReplyTo(‘(email visible only to moderators and staff)’, ‘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 visible only to moderators and staff)>n”; // your mail
$headers .= “To: ”blog” <(email visible only to moderators and staff)>n”; // mail to post
$headers .= “Content-Type: text/plain; charset=UTF8; format=flowed n” ;$headers .= “Content-Transfer-Encoding: 8bitn”;
$param = “-f <(email visible only to moderators and staff)>”; // your mail
mail (“(email visible only to moderators and staff)”, “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/ -
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 visible only to moderators and staff)>n”; // your mail
$headers .= “To: ”blog” <(email visible only to moderators and staff)>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: 8bitn”;
$param = “-f <(email visible only to moderators and staff)>”; // your mail
wp_mail( “(email visible only to moderators and staff)”, “this is a test”, “can you help me?”,$headers,$param); -
my gmail can receive email,but wordpress blog can’t receive the email.i not sure whether wordpress have some limited?
-
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.