为Drupal创建一个简单的SMTP模块

时间:2012-04-20 11:33:41

标签: php email smtp drupal-modules

我想写一个简单的Drupal7模块,它包含以下代码,用于发送邮件。不要让我使用Phpmailer或其他人。你能帮忙吗?非常感谢!

<?php

    include('Mail.php');

    $recipients = array( 'someone@example.com' ); # Can be one or more emails

    $headers = array (
        'From' => 'someone@example.com',
        'To' => join(', ', $recipients),
        'Subject' => 'Testing email from project web',
    );

    $body = "This was sent via php from project web!\n";

    $mail_object =& Mail::factory('smtp',
        array(
            'host' => 'prwebmail',
            'auth' => true,
            'username' => 'YOUR_PROJECT_NAME',
            'password' => 'PASSWORD', # As set on your project's config page
            #'debug' => true, # uncomment to enable debugging
        ));

    $mail_object->send($recipients, $headers, $body);

0 个答案:

没有答案