Re: PHP mail problem: partially solved...

Paul Spicer <[email protected]>
Newsgroups gmane.org.user-groups.jaxlug
Message-ID <CANsvRLCHRe=0oQD29sLj2iLXyFw7+1LGT6b25eH8Fcei6btOZQ@mail.gmail.com>
Most peculiar... Your solution seems to work, Ozz, but in a most unorthodox
manner...

Your method allows the email to be sent "from" pspicer (as far as the SMTP
server is concerned), but the $header line rewrites who the message is from
on the receiving end.

While not the solution I was expecting, this will do quite nicely. Thank you
very much!

On Thu, Sep 29, 2011 at 7:55 AM, <[email protected]> wrote:

> > Thanks to everyone for their suggestions. Here's what I've figured out
> and
> > where I'm stuck:
> > I had my email domain listed in the "mydomains" line of main.cf. That's
> > why
> > the mails were only being handled on my local machine and not going out
> to
> > the proper SMTP server. I took it out and was able to send a test message
> > by
> > telneting into localhost. However, when I try to send a mail through PHP,
> > it
> > gets rejected on the grounds of "unknown user account" on the server.
> > Further investigation reveals PHP is using www-data as it's user and, for
> > whatever reason, it's not using the name I specify in the $headers
> > variable
> > of my PHP script... Here's the script I'm using:
> >
> > $to="pspicer-3Q2Tfjf0mexWk0Htik3J/[email protected]";
> > $subject="Test";
> > $body="Testing";
> > $headers="From: pspicer-3Q2Tfjf0mexWk0Htik3J/[email protected]\r\nReply-to: pspicer-3Q2Tfjf0mexWk0Htik3J/[email protected]";
> >
> > $mail_sent=@mail($to,$subject,$body,$headers);
> > echo $mail_sent ? "Message sent." : "Message failed.";
>
> Try making the following changes:
> $to="pspicer-3Q2Tfjf0mexWk0Htik3J/[email protected]";
> $subject="Test";
> $body="Testing";
> $headers="From: pspicer-3Q2Tfjf0mexWk0Htik3J/[email protected]\r\nReply-to: pspicer-3Q2Tfjf0mexWk0Htik3J/[email protected]";
> // Add force from (next 2 lines)
> $set_force_from = "pspicer-3Q2Tfjf0mexWk0Htik3J/[email protected]";
> $force_from = "-f $set_force_from";
> // Add force_from to the mail command (after the headers).
> $mail_sent=@mail($to,$subject,$body,$headers,$force_from);
> echo $mail_sent ? "Message sent." : "Message failed.";
>
>
> Regards,
> Ozz.
>
>
> ---------------------------------------------------------------------
> Archive      http://marc.info/?l=jaxlug-list&r=1&w=2
> RSS Feed     http://www.mail-archive.com/[email protected]/maillist.xml
> Unsubscribe  [email protected]
>
>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.