Re: Setting PHP to use SMTP

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Dave M G wrote:

> PHP List,
> 
> In an effort to make emails that I send through PHP scripts not be
> mistaken for spam, it seems that one thing I need to do is make sure
> that the emails are sent via SMTP.
> 
> Right now, if I check my PHP generated emails with Spamassassin, it says:
> 
> -0.0 NO_RELAYS Informational: message was not relayed via SMTP
> 
> It's not deducting points, but I think the fact that it mentions it
> indicates I might be better off using SMTP.
> 
> Looking at phpinfo, it says this about my PHP/SMTP settings:
> 
> sendmail_from no value no value
> sendmail_path /usr/sbin/sendmail -t -i /usr/sbin/sendmail -t -i
> SMTP localhost localhost

This last item is only applicable under Windows; if you are using *nix
mail() will use whatever sendmail (or sendmail gateway, eg to qmail) is
found when php is compiled. The fact that you have a sendmail_path sortof
suggests you are probably on *nix :-)

The sendmail-from is also a Windows only setting.

> 
> I take this to mean that I don't have a default "from" address, but that
> it knows where my SMTP server is.

Again, SMTP server only if you are running Wndows and have an MTA, such as
Mercury, installed. As far as the sender address is concerned, see the
fifth argument to mail() in the docs - this is only relevant under *nix as
there is the Windows sendmail-from setting.
> 
> However, the last variable, where it's set to "localhost", is not so
> clear to me. Does this mean PHP is using the SMTP server on localhost?
> Does this need to be changed in order for PHP to actually send via SMTP
> since it doesn't seem to be doing so now?

If you are on *nix and want to send mail via SMTP, you need something like
http://phpmailer.sourceforge.net/ It has provision to set all the sender
type information, send mails with attachments, HTML mail if you wish to
inflict such on others, andd more.

> 
> Beyond that, I have some follow up questions:
> 
> My virtual hosting service is the kind where I have two IP addresses,
> and I can add as many domain names as I want to my account. Does that
> mean that if I set a default email address in "sendmail_from" that it
> will apply to all my domains? Is there a way to localize the setting on
> a domain by domain basis? Or is this a question I need to take to my
> hosting service provider?

If you are going to use an SMTP class such as phpMailer, you can set this
info on a per-script basis if you so desire, or have a different parent
class with different info for each domain.

> And last... how exactly do I set the variables? Do I have to manually
> edit php.ini and then restart Apache? Is there a command I should be
> running?
> 
> Thank you for any and all advice.


Cheers
-- 
David Robley

IBM: I Buy Macinstosh
Today is Prickle-Prickle, the 70th day of Bureaucracy in the YOLD 3172. 

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


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux