我在WordPress中创建了一个新的自定义页面来测试发送电子邮件,这是我的代码......
<?php
/*
Template Name:testemail
*/
get_header();
add_filter( 'wp_mail_from_name', 'my_mail_from_name' );
add_filter('wp_mail_content_type',create_function('', 'return "text/html";'));
function my_mail_from_name( $name )
{
return 'nameeeeee';
}
wp_mail('salwaieh@gmail.com', 'The subject1', '<p>The <em>HTML</em> message</p>');
wp_mail('salwaieh2012@gmail.com', 'The subjectx', '<p>The <em>HTML</em> message</p>');
wp_mail('salwaieh@hotmail.com', 'The subject2', '<p>The <em>HTML</em> message</p>');
wp_mail('salwaieh@yahoo.com', 'The subject3', '<p>The <em>HTML</em> message</p>');
$to = 'salwaieh@yahoo.com';
$subject = 'The subject4';
$message = 'The subject4 The subject4 The subject4The subject4 The subject4 The subject4';
$headers = 'From: webmaster@example.com' . "\r\n" .
'Reply-To: webmaster@example.com' . "\r\n" .
'X-Mailer: PHP/' . phpversion();
mail($to, $subject, $message, $headers);
$to = 'salwaieh2012@gmail.com';
$subject = 'xxxxxxxxx';
$message = 'The subject4 The subject4 The subject4The subject4 The subject4 The subject4';
$headers = 'From: webmaster@example.com' . "\r\n" .
'Reply-To: webmaster@example.com' . "\r\n" .
'X-Mailer: PHP/' . phpversion();
mail($to, $subject, $message, $headers);
get_footer(); ?>
我收到了Yahoo和Hotmail帐户的所有电子邮件,但为什么我在Gmail收件箱中找不到任何电子邮件?
答案 0 :(得分:0)
许多电子邮件服务最近对垃圾邮件非常严格,因此我的所有Wordpress联系表单都遇到了问题。我最终用wp-smtp插件解决了这个问题。它更像是一种解决方案,而不是一种实际的解决方案......