Mailbox shows the sender name as "Apache", because the mail I am autosending is being sent from a Perl CGI program. How do I change it to something else?
You just need to add a From:
header. By default there is none.
echo "Test" | mail -a "From: Someone <[email protected]>" [email protected]
You can add any custom headers using -a
:
echo "Test" | mail -a "From: Someone <[email protected]>" \
-a "Subject: This is a test" \
-a "X-Custom-Header: yes" [email protected]
mail
. Can you check whether it works with a custom header instead? –
Trott From: Someone <[email protected]>: No such file or directory
It's as if it's treating the email address as a directory. Both commands fail on Fedora 17. You passed a string which is not a file into the '-a' option, this cannot work. –
Gilliangilliard mail
expect -a
to be passed a string, not a file. What is the email software you are using on Fedora? –
Trott mail -s "$(echo -e "This is the subject\nFrom: Paula <[email protected]>\n
Reply-to: [email protected]\nContent-Type: text/html\n")"
[email protected] < htmlFileMessage.txt
the above is my solution..just replace the "Paula" with any name you want e.g Johny Bravo..any extra headers can be added just after the from and before the reply to...just make sure you know your headers syntax before adding them....this worked perfectly for me.
mail -s "$(echo -e "This is the subject\nFrom: Paula <[email protected]> Reply-to: [email protected]\nContent-Type: text/html\n")" [email protected] < htmlFileMessage.txt
–
Gilliangilliard You can use the "-r" option to set the sender address:
mail -r [email protected] -s ...
In case you also want to include your real name in the from-field, you can use the following format
mail -r "[email protected] (My Name)" -s "My Subject" ...
-r
is a GNU-ism. Not available on BSD. –
Hiroshima If no From: header is specified in the e-mail headers, the MTA uses the full name of the current user, in this case "Apache". You can edit full user names in /etc/passwd
It depends on what sender address you are talking about. The sender address visble in the recipients mailprogramm is extracted from the "From:" Header. which can probably easily be set from your program.
If you are talking about the SMTP envelope sender address, you can pass the -f argument to the sendmail binary. Depending on the server configuration you may not be allowed to do that with the apache user.
from the sendmail manpage :
-f <address>
This option sets the address of the envelope sender of a
locally-generated message (also known as the return path).
The option can normally be used only by a trusted user, but
untrusted_set_sender can be set to allow untrusted users to
use it. [...]
On Ubuntu 14.04 none of these suggestions worked. Postfix would override with the logged in system user as the sender. What worked was the following solution listed at this link --> Change outgoing mail address from root@servername - rackspace sendgrid postfix
STEPS:
1) Make sure this is set in /etc/postfix/main.cf:
smtp_generic_maps = hash:/etc/postfix/generic
2) echo 'www-data [email protected]' >> /etc/postfix/generic
3) sudo postmap /etc/postfix/generic
4) sudo service postfix restart
© 2022 - 2024 — McMap. All rights reserved.