Re: [PHP] php sendmail_from

2012-01-10 Thread Duken Marga
Actually, you can send an email from explicit email addres without
modifying htaccess or php ini.
In simple words, PHP uses MTA (like postfix or sendmail) to send email to
another email address. An email consist of header, body, and mime (for
example an attachment). Sender, receiver, Subject, and other parts of
message are laid in header. Body is used to store the message.

We can use PHP to write the header of message so we can change sender email
address. For example:

?php
$to  = 'nob...@example.com';
$subject = 'the subject';
$message = 'hello';
$headers = 'From: webmas...@example.com' . \r\n .
'Reply-To: webmas...@example.com' . \r\n .
'X-Mailer: PHP/' . phpversion();

mail($to, $subject, $message, $headers);
?

You can see the example above from PHP manual.

On Tue, Jan 10, 2012 at 1:53 AM, alexus ale...@gmail.com wrote:

 I need to change sendmail from field, I added following to my .htaccess:

 php_value sendmail_from 'x...@xxx.xxx'

 and tried to send out an email, but it still comes from apache@FQDN

 through phpinfo(); I see as local value my email address x...@xxx.xxx

 --
 http://alexus.org/

 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php




-- 
Duken Marga
http://duken.info


Re: [PHP] php sendmail_from

2012-01-09 Thread Fatih P
On Mon, 2012-01-09 at 13:53 -0500, alexus wrote:
 I need to change sendmail from field, I added following to my .htaccess:
 
 php_value sendmail_from 'x...@xxx.xxx'
 
 and tried to send out an email, but it still comes from apache@FQDN
 
 through phpinfo(); I see as local value my email address x...@xxx.xxx
 
 -- 
 http://alexus.org/
 



try this before sending mail:

$sender = 'some...@somewhere.com';

if (ini_get(sendmail_from) == null || ini_get(sendmail_from) == )
{
ini_set(sendmail_from, $sender);
}

it is working fine for me


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] php sendmail_from

2012-01-09 Thread alexus
do you know if Drupal uses that too?

On Mon, Jan 9, 2012 at 10:16 PM, Fatih P fatihpirist...@gmail.com wrote:
 On Mon, 2012-01-09 at 13:53 -0500, alexus wrote:
 I need to change sendmail from field, I added following to my .htaccess:

 php_value sendmail_from 'x...@xxx.xxx'

 and tried to send out an email, but it still comes from apache@FQDN

 through phpinfo(); I see as local value my email address x...@xxx.xxx

 --
 http://alexus.org/




 try this before sending mail:

 $sender = 'some...@somewhere.com';

 if (ini_get(sendmail_from) == null || ini_get(sendmail_from) == )
 {
        ini_set(sendmail_from, $sender);
 }

 it is working fine for me




-- 
http://alexus.org/

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php