我遇到了wierd问题。我正在使用"WP电子邮件模板"插件与mandrill。我还在"主题我的登录"插件中使用一个自定义文件,该插件需要在收到$_POST后发送电子邮件。这是一个代码
$location = $_SERVER['DOCUMENT_ROOT'];
global $wpdb;
if ( ! isset( $wpdb ) ) {
include( $location . '/wp-config.php' );
}
global $current_user;
/************** Wp_mail Works Fine when placed here *************/
if( isset( $_POST['organisation_name'] ) ) {
/************** Wp_mail doesnot Work when placed here *************/
$current_user = wp_get_current_user();
}
Wp邮件放在isset($_POST)外部时工作正常,但放在内部时不工作。我已经仔细检查了if语句是否正确执行。EDIT:这是条件之前的Print_r($_POST)没有什么有趣的
Array
(
[organisation_name] => iDevels
[representative_name] => Test Ato
[representative_contact] =>
[course-name] => ITIL 2011
[course-level] => Foundation (3 days)
[start-date] => 17/02/2015
[end-date] => 19/02/2015
[no-candidate] => 2
[trainer-required] => true
[trainer-name] =>
[exam-required] => true
[exam-date] => 19/02/2015
[exam-time] => 12:00
[exam-type] => Paper
[proctor-name] =>
[delivery-contact] => asdasd
[delivery-phone] => 234234
[delivery-address] => asdasd
[delivery-city] => asdasd
[delivery-postcode] => asdasd
[delivery-country] => AT
[exam-papers] => delivery location
[training-venue-location] => Same as delivery location
[training-contact] => asdasd
[training-phone] => 234234
[training-address] => asdasd
[training-city] => asdasd
[training-postcode] => asdasd
[training-country] => AT
[_wpnonce] => cc65d65d0c
[_wp_http_referer] => /customer-area/?settings=order-training
)
我不确定在出现这种情况之前它是如何发送邮件的。我刚刚将mandrill设置从进行API调用更改为实际使用Mandrills SMTP设置,这解决了问题。