1

From what should be a non-trivial task, I find this very confusing. My requirement is to send HTML email upon webform submission. Here is what I have now.

If from address is set as domain email address ([email protected]) that is set as system's email address, set via Admin >> Configuration >> System, the email was sent as non HTML email. This is strange, because I dpm the email content before executing drupal_mail, and it shows up as properly formatted HTML. I could tolerate this for now. Here comes the trivial part.

If from address is set as non-domain email address, such as [email protected], the email sent, never reached the recipients, but is logged as sent (I use mail_logger module) under appropriate email key. I have checked spam folder but it is not there either.

My question is, does drupal 7 require the from email address to be that of the same domain or set as system email? (I would have expect a failed message and is logged into mail_logger)

Any suggestions would help.

3 Answers 3

2

This happens becouse Gmail seems to block these messages as they are often used for spoofing. Using the SMTP mailer plugin https://www.drupal.org/project/smtp and authenticating using your [email protected] should solve the problem.

1
  • Wow this is awesome! I was going through the trouble of attempting to install postfix and relaying the message via SMTP server.
    – rwaery
    Commented Sep 30, 2014 at 13:46
1

Its not necessary to have from address of the same domain but its recommended to have so. If you are using some other domain email address and if the mail server is properly configured than also it should send an email, although it may go in the spam folder. If the mails are not getting sent at all than check the error logs of mail on server, from there you can get the exact issue.

By default, Webform sends email in plain text. To send email in HTML format in an easy way you may use the Mime Mail module:

  • It permits users to receive HTML email and can be used by other modules. The mail functionality accepts an HTML message body, mime-endcodes it and sends it.
  • If the HTML has embedded graphics, these graphics are MIME-encoded and included as a message attachment.
  • Adopts your site's style by automatically including your theme's stylesheet files in a themeable HTML message format
  • If the recipient's preference is available and they prefer plaintext, the HTML will be converted to plain text and sent as-is. Otherwise, the email will be sent in themeable HTML with a plaintext alternative.
  • Allows you to theme messages with a specific mailkey.
  • Converts CSS styles into inline style attributes.
  • Provides simple system actions and Rules actions to send HTML email with embedded images and attachments.

Though its not necessary to use the Mime mail module for sending the mails in HTML format, but it provides the easy way to do so. However if you want to do it through custom module than check this: How to send HTML email

2
  • Thanks for your input. Even though HTML email is an issue, it is not my main concern now. I have tested using different email address for the from value of drupal_mail but the only one that works is the domain name email address that is also set as system email address. This is really strange, because all scenarios I mentioned were recorded under mail_logger as successfully sent messages.
    – rwaery
    Commented Sep 27, 2014 at 18:27
  • @rwaery Have you checked the server mail logs as well? There is must be something that can point us in the right direction, also you have tried for different recipient? Commented Sep 27, 2014 at 18:32
1

try this function drupal_mail() Example code:

drupal_mail('system', 'mail', '[email protected]', language_default(), array(
  'context' => array(
    'subject' => 'Test e-mail',
    'message' => '
      <p>Lorem <a href="http://google.com">ipsum dolor sit amet</a>, consectetuer <b>adipiscing</b> elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat.</p>
      <p>Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat.</p>
      <p>Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla facilisis at vero eros et accumsan et iusto odio dignissim qui blandit praesent luptatum zzril delenit augue duis dolore te feugait nulla facilisi.</p>
    ',
  ),
  '[email protected]',
));

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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