1

For some reason my Drupal website does not sends email from contact form. Can you help me where could be a problem?

It also does not send emails to administrator for newly added comments.

Just to mention, that only email it sends is when registered user requests for new password.

Thank you in advance!

  • Enable Database Logging module and check Log Messages. – niksmac Mar 17 '14 at 14:12
  • tnx, but there is nothing about sending email from contact form in drupal's logs... can you give me some idea why? and also, i can send message from user's personal page (from mysite.com/users/myusername). – user198003 Mar 18 '14 at 10:38
3

There could be many reasons but here are a few things to check.

  1. Check your logs. Watchdog may tell you the source of the error. For D7, it's at /admin/reports/dblog
  2. Test other mail functions like the reset password link.
  3. Make sure you have a valid email address set: The site email address (used when sending notification emails, and the default for most all modules that send emails) can be set via the Site Configuration > Site information page (admin/settings/site-information).
  4. Check your permissions if you are sending email from a module like webforms.
  5. If you have SSH access to your server, test the mail settings from there.

    <?php
    $to = "your@email.com"; // REPLACE
    $subject = "Test mail";
    $message = "Hello! This is a simple email message.";
    $from = "noreply@eample.com";
    $headers = "From:" . $from;
    mail($to,$subject,$message,$headers);
    echo "Mail Sent."; Make sure to replace the "to" address, save it as mail.php, and run it using "php mail.php". If you get email from that, then the problem is specific to Drupal, and if not, then your server isn't sending email at all and you should contact your host.

| improve this answer | |
  • sorry, but it looks like you did not read my post at all - i do have valid email address defined and i can send reset password email. – user198003 Mar 18 '14 at 10:36
1

If you are sending this emails from the same email account as the destination it is posible that the email is in your spam folder.

This is because your mail client does not recognize as their own.

Solution: check emails from the main account as not spam.

$my_module = 'foo';
$my_mail_token = 'bar';
$from = variable_get('system_mail', 'info@test.net'); // Fill your administrator mail here!
$message = array(
  'id' => $my_module . '_' . $my_mail_token,
  'to' => $from, // the same email account!
  'subject' => 'TEST EMAIL',
  'body' => array('test'),
  'headers' => array(
    'From' => $from, 
    'Sender' => $from, 
    'Return-Path' => $from,
  ),
);
$system = drupal_mail_system($my_module, $my_mail_token);
// The format function must be called before calling the mail function. 
$message = $system->format($message);

if ($system->mail($message)) {
  // Success.
}
else {
  // Failure.
}
| improve this answer | |
0

Sometimes it confuses that email at admin/config/system/site-information will receive the email from contact form.

For the contact form you can check Recipients Email at admin/structure/contact in the respective category.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.