LaoBlog

PHP, change default email sender and address


The php.ini file lets you configure the default sender (the From in the email header) and email addressIf you have multiple php.ini files (for example one for cli, one for apache, etc), you need to find the right one for your purpose or even change 'em all.EX: You want to set the From field instead of thedefault www-data to noreply, and the email address of the sender as noreply@mydomain.net in a Linux system (for Windows it's different).To accomplish this, add the following line in your php.ini file:sendmail_path ='/usr/sbin/sendmail -t -i -fnoreply@mydomain.net -Fnoreply'Where:-F "name": Sets the name to put in the From: header.-f address: Sets the From: address. This is just the E-mail address only, not the name.Save, reboot all the involved services (webserver, php-fpm...) and you're doneReference: http://www.courier-mta.org/sendmail.html