This code tends to send out hundreds of similar emails. I am totally stuck, just got a notice that postfix is not responsible.

So, this code might somehow be responsible for mass-spamming. The mails that are sent are entirely identical, only difference is sending time. And, form is only submitted once, then it starts the spamming.

<?php function order_login_mail_send($form_values) {
    global $user;
    $module = 'smb_order_login';
    $key = 'smb_order_login_mail';
    $to = $form_values['email'];
    $from = $user->mail;
    $params = $form_values;
    $language = language_default();
    $send = TRUE;
    $result = drupal_mail($module, $key, $to, $language, $params, $from, $send);
    if ($result['result'] == TRUE) {
        drupal_set_message(t('The link has been sent in an email to the user.'));
        watchdog('order login links',"Order login sendt from $from to $to");
    } else {
        drupal_set_message(t('There was a problem sending your message and it was not sent.'), 'error');
    }
}

function order_login_mail($key, &$message, $params) {
    $language = $message['language'];
    $msg_params = array(
        '@site-name' => variable_get('site_name', 'Drupal'),
    );
    switch ($key) {
        case 'smb_order_login_mail':
            $message['subject'] = t('@site-name order payment', $msg_params);
            $message['body'][] = $params['body'];
            break;
    }
};?>

Furthermore, the form responsible for sending the mail (in a block):

<?php function order_login_form($form, $form_state, $order, $token) {
    $msg_params = array(
        '@site-name' => variable_get('site_name', 'Drupal'),
    );

    $default_message = t('You have recieved a login link from a seller at @site-name. ', $msg_params);
    $default_message .= t('You may now pay the order by clicking: ');
    $default_message .= url('cart/customerpay/' . $token, array('absolute' => true));

    $form = array();

    $form['group'] = array(
        '#type' => 'fieldset',
        '#title' => t('Send betalingslink til kunde'),
        '#collapsible' => true,
        '#collapsed' => true,
    );
    $form['group']['token'] = array(
        '#type' => 'hidden',
        '#value' => $token
    );
    $form['group']['message'] = array(
        '#markup' => t('Send en email til kunden slik at kunden kan betale med sitt kredittkort.'),
    );
    $form['group']['body'] = array(
        '#type' => 'textarea',
        '#title' => t('Teksten som skal sendes'),
        '#default_value' => $default_message,
        '#rows' => 2
    );
    $form['group']['type'] = array(
        '#type' => 'radios',
        '#title' => t('Send tekst som'),
        '#options' => array('email' => 'Epost'),
        '#default_value' => 'email'
    );


    $form['group']['email'] = array(
        '#type' => 'textfield',
        '#title' => t('E-postaddresse'),
        '#description' => t('Email to send to.'),
        '#states' => array(
            'visible' => array(// action to take.
                ':input[name=type]' => array('value' => 'email'),
            )
        )
    );
    $form['group']['submit'] = array(
        '#type' => 'submit',
        '#value' => 'Send link',
    );
    if ($order->status != 'cart' && $order->status != 'completed'){
        drupal_set_message(t('The order is not in cart mode. It must be in cart mode if you want to send a link to the customer.'),'warning');
        $form['group']['submit']['#disabled'] = true;
    }
    
    if ($order->mail){
    // $form['group']['email']['#default_value'] = $order->mail;
    }

    return $form;
};?>

Thanks for all help!

Comments

sun’s picture

Priority: Critical » Normal
pasqualle’s picture

Status: Active » Closed (cannot reproduce)

From the code it is not visible where do you call the order_login_mail_send() function. There should be the source of your problem.