I have the following SMTP Configuration:
Regardless of what I have above, when I use the Email Agent in the VPE I can type anything I want in the From field and that is what will show when the recipient gets the email. If can be a full email address like name@company.com or something simple such as David – both work.
When I use sendmail from a script, the email always shows as coming from root [root@hostname.company.com] (display name is root, email address is root@hostname.company.com). This happens whether I log in as David or Admin.
My basic script works like this:
(echo "Subject: Your Password"
echo "To: recipient@company.com"
echo "Content-Type: TEXT/HTML; charset=US-ASCII"
echo ""
echo ""
echo ""
echo "Your password is: 12345"
echo "
") | sendmail recipient@company.com
I have tried adding “From: sender@company.com” and –fsender@company.com but it always comes out as root [root@hostname.company.com]. Not sure if it makes a different but 100% of the mail is staying internal which is why I want to change the name of the Sender to something like vpn@company.com.
Thanks,
David
APM 11.5.3
SMTP has two Froms, one is in the SMTP commands (FROM xxx) and the other is in the message headers (From: xxx). I think there is some way to get sendmail to read the headers to infer the “FROM” it should use, but you can just use the -f switch to set it when you call it from a script. This is more of a unix question rather than APM: The delivery agent used by APM is completely separate from sendmail.
Your command would then look like:
echo “message data here” | sendmail -f 'ops-noreply@company.com’ 'recipient@company.com
Google “sendmail from address” for more in depth discussion on this topic and information about how different user agents need this to be formatted to display a “friendly name” part of the address. Also be sure to sanitize username input if it’s from an external source, especially those usernames with apostrophes, parens, or shell script injection attacks.
It does not work for me. Even using the simplest format as you have shown above still comes out as root [root@hostname.company.com]. I tried with single quotes, double quotes, no quotes, space after the -f, no space after the -f. Does that one line sendmail command work for you?
These are two different functionalities. In order to have you sendmail command use a different from address you will have to edit the FromLineOverride=YES field in /etc/ssmtp/ssmtp.conf. This is SOL isn’t exactly what you are doing, but it is leveraging the same functionality and explains how to edit the conf file.
These are two different functionalities. In order to have you sendmail command use a different from address you will have to edit the FromLineOverride=YES field in /etc/ssmtp/ssmtp.conf. This is SOL isn’t exactly what you are doing, but it is leveraging the same functionality and explains how to edit the conf file.
The FromLineOverride=YES entry does work however it does not survive a reboot. Another user posted a very similar question and reference was made to 404 Page not found | BIG-IP Documentation which talks about modifying /config/startup. Would this be the way to go and if so would I call a script just to replace /etc/ssmtp/ssmtp.conf with an updated version? It seems odd that if we are supposed to use tmsh modify /sys outbound-smtp to set the mailhub that it would not work for other parameters in the file.
The FromLineOverride=YES entry does work however it does not survive a reboot. Another user posted a very similar question and reference was made to 404 Page not found | BIG-IP Documentation which talks about modifying /config/startup. Would this be the way to go and if so would I call a script just to replace /etc/ssmtp/ssmtp.conf with an updated version? It seems odd that if we are supposed to use tmsh modify /sys outbound-smtp to set the mailhub that it would not work for other parameters in the file.