0
votes

I'm in need of help for a custom form in which emails are not being sent.

Context: Within Drupal, I have installed the following modules: PHPMailer, SMTP Authentication Support, Mail System and Mime Mail.

Configuring the above modules you have the option to test your configurations and when preforming such tests emails are being sent properly. However, when writing a module for a form, emails are not being sent.

I don't get any type of erros nor message. I just don't get the email.

Here is the snipped of code that I'm using:

function application_form_submit($form, &$form_state) {
        $subject = "testing web form";
        $body = array();
        $body[] = "Mail body";
        $send = FALSE;
        $mail_message = drupal_mail('application', 'apply-jobs', '[email protected]', language_default(), $params = array(), $from = '[email protected]', $send);
        $mail_message['subject'] = $subject;
        $mail_message['body'] = $body;

        $mail_system = drupal_mail_system('application', 'apply-jobs');
        $mail_message = $mail_system->format($mail_message);

        $mail_message['result'] = $mail_system->mail($mail_message);
}

Suggestions?

2
Does your hosting provider block port 25?Dummy Code

2 Answers

0
votes

You've got an odd way of defining optional parameters. This bit:

$from = '[email protected]'

will evaluate to... nothing

Try changing your drupal_mail() call like this:

$mail_message = drupal_mail('application', 'apply-jobs', '[email protected]', language_default(), array(), '[email protected]', $send);
0
votes

I found the solution to my question. The solution is:

The Mail System module allows one to Configure Mail System settings per module, which means that I had to create new mail system for my customized module an indicate the mail system that I want to use. After I did this, all my email are being sent without any problems.

Hope this helps someone, as there is very little information about this.

Thank you all.