Ferdi writes:

> I have met with little success sending mail from PHP. I have used mainly the
> mail() function but have also tried imap_mail() which the documentation says
> is just a wrapper around mail().

IMAP is only incoming (at least, the protocol is - the clue is in the
name "Internet Message Access Protocol" - I can't say anything about
imap_mail). I agree with others, the easiest solution is a local MTA
such as sendmail, or, preferably, something more simple.

> Here is my understanding of the situation:
> On Windows (WampServer 2.0i ) I manage to send email after setting SMTP =
> smtp.someserver.com. I guess this works because the server I use relays all
> mail received; it does not check if the user has been registered or
> not.

Oof. Yes, most remote/ISP MTAs these days will require some kind of
authentication, which is why it is best (IMO) to use a local MTA. It
won't mean you don't have to authenticate to the remote MTA, but it will
push the responsibility of configuring the MTA onto someone who knows
what it's all about.

> On Linux (Centos 5.XX, XAMPP 1.7.2), the above function [mail()] does not
> work. On Linux, what I have understood, is that the smtp server settings in
> php.ini do not matter. The sendmail / mail (something like that)

What happens if you type 'man mail'?

> utility is
> called which sends the mail. I have put in the correct sendmail_path setting
> in php.ini, but, I guess this utility is not configured since I don't
> receive the mail and running the code does not throw up errors or warnings.

You can try sending email from the commandline using 'mail' or even
sendmail, to see if it works.

You could try installing something simple locally (i.e. as "your" user),
perhaps msmtp, which is a piece of cake to setup, especially compared
with stuff like sendmail (which it is, anyway, compatible with, to a
large extent).

> What I need to achieve is the ability to send attachments in an email from
> PHP. I would like one of the following options (in order of preference):
> 1. Create an email account (specifically Google Apps Mail) and send email as
> that user. This will not be trivial. I will need to get a fix on
> authenticating, logging in etc.

A simple config to send mail through Google Apps for Domains via a local
msmtp installation follows:
host smtp.googlemail.com
tls on
tls_starttls on
port 587
tls_trust_file /home/YOUR_USER/.certs/equifax.pem
auth on
logfile ~/.logfiles/msmtp.log

account foo
from f...@yourdomain
user f...@yourdomain

You'll need to get the referenced tls_trust_file but I forget where
from. It will be different anyway, depending on the system - for example
from looking at the msmtp docs it seems you can simply install a package
on Debian.

> 3. Configuring the sendmail utility on Linux

>From what I remember, I wouldn't recommend sendmail :) It's really
complicated, and probably overkill for what you want.


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

Reply via email to