Closed (fixed)
Project:
Printer, email and PDF versions
Version:
6.x-1.6
Component:
Code
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Reporter:
Created:
13 May 2009 at 16:33 UTC
Updated:
13 Sep 2012 at 12:21 UTC
Otherwise mail headers are not friendly and expose server details.
In print_mail.inc function print_mail_mail() I added these lines which fixed it:
$message['headers']['From'] = 'info@example.com'
$message['headers']['Reply-To'] = 'info@example.com'
Of course, the values should be retrieved from the form dynamically. What I did is to save fld_from_addr and fld_from_name as globals in function print_mail_form_validate() and retrieve them in function print_mail_mail() - like this:
In function print_mail_form_validate() I did -
$custom_from_name = $form_state['values']['fld_from_name'];
$custom_from_address = $from_addr;
In function print_mail_mail() I did -
$message['headers']['From'] = $custom_from_name;
$message['headers']['Reply-To'] = $custom_from_address;
HOWEVER - Only the form_address works OK; the name is shown like this: the_expected_name@servername.domain.com
Could anyone help with this?
Comments
Comment #1
jcnventuraThe drupal_mail() function itself handles the From field, so that's probably why it's not working for you.. Your mail server is adding the domain to it because it's configured to do so.
The 'Reply-To' field however would be a good feature to add to the module. It's nice to know I'll have stuff to do for 1.8.
João
Comment #2
jcnventuraOn the other hand, it seems that the reason why the 'Reply-To' field is not being set is because of a conscious decision by Drupal core developers not to do it. See #330084: Setting Reply-To in mails to the same as From is redundant..
Since I have to agree with them that there's no reason to add the 'Reply-To' field to the same value as the 'From' field, there's nothing I can do.
João
Comment #3
amir simantov commentedHi João,
Thanks for the reply and giving a thought (and another one...)
I will have to think about it and will get back to you.
Amir
Comment #4
olbion commentedNot sure if this goes here. I did a little hack to make mail_print use Reply-To instead of From. The From address will be the site default, and the Reply-To whatever user sent the message's email. That way, the message appears to be from the website but if the receiver tries to reply, it will also work and go to the user who sent it. Also, I'm thinking that this would be a way to prevent mail from being considered spam. Ie, my server might not have the permission to send email from another users email. Not too sure about this though.
Anyway, here's what I did:
Line 297 of print_mail.inc:
Then on line 350 I use the param from above to populate the headers that will be sent with the email:
Hope this is useful to someone
Comment #5
Yuri commented#olbion your #4 solution sound good, especially because Gmail flags all emails as spam, which are send with the 'send a friend' method.
My problem is that the code in print_mail.inc has changed a lot since your post, and I don't know how and where to insert it.
You are still using it this way?
Comment #6
jcnventuraI just changed this to a solution similar to the one in #4, as part of the fix for #1678180: Gmail flags the outgoing 'send by email' messages as spam.