Setting "From: " in Sendmail - email

I have an IRC server that automatically sends out a generic email to a user upon registration. The software (Anope) uses Sendmail to send the generic email upon registration and another email, if they forgot their password. The software requires me to specify the path to Sendmail - that's it.
When a user receives the confirmation email, they see the sender's name as "From: ircserver (ircserver#hostname.com)". Basically I'd like to change/set the name of the sender (i.e., the name in the From: field) to something more meaningful, such as "From: My Website (ircserver#hostname.com)" or "From: My Website IRC Network (ircserver#hostname.com)". (I'll come up with something later.)
I read the Sendmail README a few times, and found something similar (or so I think) to what I want (Masquerading), but that's for setting your hostname as another. Sendmail has a -F switch that sets the "From: " field, but that only works when I'm manually typing/sending the email. I have tried searching online for an answer and got results for PHP and such, which is not what I want.
OS: Debian 6.0.7
Sendmail version: 8.14.3
Thanks in advance for all your help!
Julian

You have to modify services.conf file and use -F option as you suggested :
# SendMailPath <path> [REQUIRED]
#
# This is how we should call SendMail to send a mail. It must be
# called with all parameters needed to make it scan the mail input
# to find the mail recipient; consult your SendMail documentation.
#
# Postfix users must use the compatible sendmail utility provided
# with it; this one usually needs no parameters on the command line.
# Most sendmail applications (or replacements of it) require the -t
# option to be used.
SendMailPath "/usr/sbin/sendmail -F 'Your Name'"

Related

How to set sender name in mailutils while preserving the sender address

I have set up mailutils in ubuntu 20.04, I can send an email using the command below
echo 'this is a body' | mail -s 'Test Email' -r noreply#domain.com myaddress#example.com
but the first problem with the above command is that it sends the mail with the name 'Ubuntu', which is my current user, only the sender name is not good in this case, the sender address is the one I specified. (Ubuntu <noreply#domain.com>).
Then in this second command when I try to send specifying the sender's name:
echo 'this is a body' | mail -s 'Test Email' -r 'SenderName <noreply#domain.net>' myaddress#example.com
In my email inbox it will show the following sender: Ubuntu <SenderName#mainmailserver-1-eu>
How can I change the sender name in mailutils while preserving the sender address?
The -r option sets the envelope sender. Probably try
mailx -s 'Test Email' -a 'From: SenderName <noreply#domain.net>' myaddress#example.com <<<"this is a body"
You may wish to also separately set the envelope sender, but this adds a proper From: header which controls what gets displayed more directly.
Some MUAs might still display something different if there is a separate Sender: header, which some systems automatically add when you override the default. If you need detailed control over these things, you will probably also need to separately configure your MTA (Postfix, Sendmail, what have you).

mail: Invalid header when sending mail attachment with Ubuntu

This exact question was posted by user 'anvd' on 29th July but then removed - I found it on Google Cached version...!
I'm guessing the fix was something obvious, but would be great if it wasn't removed.
I am trying this command to send an email with an attachment.
echo 'These are contents of my daily backup' | mail -s 'Daily backup' -a /tmp/filename.gz mymail#hotmail.com
The error: mail: Invalid header: /tmp/filename.gz
The email gets sent, but the attachment is not attached.
This used to work, and still dos on other systems, but not sure what has changed on one of my machines...
I just had this problem. It turns out that -a is the flag for appending headers, whereas -A is the flag for attaching files.

Sending an one-message email to a receiver by batch script file(windows)

Actually i am writing batch file to validate a text file formats. "sending an email by using lotus note" is used for reporting to receiver that any format goes right or wrong. "Sending an email" is an action after reaching if-statements.
code for sending email:
I am referencing to how can I add body to the mailto link from console Win?
if %number% equ %count% (
start "" "mailto:username in lotus note?subject=subject&body=body "
)
I am almost there, the code above start lotus note and filled in the subject&body automatically.But it don't hit the "send" button,i have to write batch script for this send action,any suggestion
Oh, i got the answer by referencing to How to send an email from one Gmail account to another one using a batch file or script?.
First, download blat from http://www.blat.net/ on the left hand side, then you will get blat.exe after unzip some download packages. Then, blat.exe should be included in the same directory of your batch file. This sendmail action allow sender to use a fake email address and in the command i show you should put down your organization or company server name & port number(generally 25).
Finally, an email can be sent by using code below:
blat.exe - -f anyAddress#mail.com -to recipient#mail.com -s Subject -body "type you body here" ^ -server hp2-server.abcd.abcdef:25
pause
some notification like "Sending stdin.txt to bla bla bla" will be shown on command windows once it succeeds.

How to send email with attachment on OpenWRT?

I have installed OpenWRT on my ruter with msmtp package.
I'm able to send regular email but I can't figure out how to add attachment.
I've searched google and it seems that I should use uuencode but I can't find proper package.
The questions are:
does uuencode or it's substitute exists for OpenWRT? If not then:
How to send email with attachment on OpenWRT without uuencode?
You can use mutt. Here is an example how to send an email with attachment:
echo "This is the message body" | mutt -a "/path/to/file.to.attach" -s "subject of message" -- recipient#domain.com
As of OpenWrt Attitude Adjustment 12.09 the mutt package is available.

Is procmail chrooted or limited in using linux commands?

im using procmail to forward emails to different folders in my Maildir.
I use these two lines to get the FROM and TO from the mail, which works pretty fine.
FROM=`formail -x"From:"`
TO=`formail -x"To:"`
These two commands return the whole line without the From: and To: prefix.
So i get something like:
Firstname Lastname <firstname.lastname#mail-domain.com>
Now i want to extract the email between < and >.
For this i pipe the variable FROM and TO grepping it like this.
FROM_PARSED=`echo $FROM | grep -o '[[:alnum:]+\.\_\-]*#[[:alnum:]+\.\_\-]*'`
TO_PARSED=`echo $TO | grep -o '[[:alnum:]+\.\_\-]*#[[:alnum:]+\.\_\-]*'`
But when i print FROM_PARSED into the procmail log by using LOG=FROM_PARSED, i get an empty string in FROM_PARSED and TO_PARSED.
But if i run these commands on my console, all works fine. I tried many other grepping methods, using grep, egrep, sed and even cut (cutting < and >). All working on console, but i use it in procmail it just returns nothing.
Is it possible that procmail is not allowed to use grep and sed commands? Something like a chroot?
I dont get any error logs in my procmail log. I just want to extract the valid email address from the FROM and TO line. Extracting with formail works, but parsing it with grep or sed fails, even if expression is correct.
Could somebody help? Maybe i need to setup procmail somehow.
Strange.
I added this to the users .procmailrc file
SHELL=/bin/bash
The users shell was set to /bin/false, which is correct because its a mail user, no ssh access at all.
You should properly quote "$FROM" and "$TO".
You will also need to prefix grep with LC_ALL=POSIX to ensure [:alnum:] will actually match the 26 well-known characters + 10 digits of the English alphabet.
You already solved this, but to answer your actual question, it is possible to run procmail in a chroot, but this is certainly not done by Procmail itself. Sendmail used to come with something called the Sendmail Restricted Shell (originally called rsh but renamed to remsh) which allowed system administrators to chroot the delivery process. But to summarize, this is a feature of the MTA, not of Procmail.