当然有一种方法:如果您只想执行一次,我建议使用一种快速且简单的方法drupal_bootstrap()...。在外部 php 文件中调用此函数来引导 Drupal,然后加载用户并发送电子邮件。这是一个伪代码:
<?php
// ...
// Change directory to Drupal root
chdir(../../);
// Bootstrap Drupal
require './includes/bootstrap.inc';
// You might want to pass DRUPAL_BOOTSTRAP_DATABASE instead
drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
$db_result = db_query('SELECT * FROM {users}');
while ($user_object = db_fetch_object($db_result)) {
// TODO: Use drupal_mail() to send desired emails
// User Name: $user_object->name
// User Email: $user_object->email
// Don't forget to pass 'em through the check_plain()
// ...
}
// ...
Run Code Online (Sandbox Code Playgroud)
在 Drupal API 中了解更多信息:。drupal_mail() drupal_bootstrap()