Fwd: [Lancaster] Help needed with email from web pages
jonath
j at jonath.co.uk
Thu Jun 28 15:38:33 BST 2007
Oooops. Sent to the wrong address. Forwarding to
lancaster at mailman.lug.ork.uk
---------- Forwarded message ----------
From: jonath <j at jonath.co.uk>
Date: 28-Jun-2007 15:37
Subject: Re: [Lancaster] Help needed with email from web pages
To: Ken Hough <kenhough at uklinux.net>
Ken,
Like Matt, I've always used the built-in mail function of php:
http://uk.php.net/manual/en/function.mail.php
The problem may be that you're not putting in the headers, but I appreciate
these aren't absolutely necessary. A typical header might be:
$headers = "From: Webmaster <webmaster at somewhere.co.uk\n";
$headers .= "X-Sender: <webmaster at somewhere.co.uk>\n";
$headers .= "X-Mailer: SMCPHP4.05(SG2001)\n";
$headers .= "Return-Path: <postmaster at somewhere.co.uk>\n\r";
[replace somewhere.co.uk as appropriate]
Also, bear in mind the following:
'Note: When sending mail, the mail must contain a From header. This can be
set with the additional_headers parameter, or a default can be set in
php.ini .
Failing to do this will result in an error message similar to Warning:
mail(): "sendmail_from" not set in php.ini or custom "From:" header missing.
The From header sets also Return-Path under Windows.' [from the PHP
web-site]
So, given you were not using a header, PHP might have been checking
php.inifor a valid 'from' address and maybe one did not exist there.
Regards,
Jonathan
On 28/06/07, Ken Hough <kenhough at uklinux.net> wrote:
>
> Hi Guys!
>
> Can you help me? I'm building a website and need to provide for sending
> email messages from within the site.
>
> I been using PHP and for test/dev purposes run my own local webserver
> (apache with mod_php). I know that the web server and the PHP bit work
> OK, because the website uses PHP successfully for a number of other tasks.
>
> Using the very simple code:
>
> <?php
> // The message
> $message = "Line 1\nLine 2\nLine 3";
>
> // In case any of our lines are larger than 70 characters, we should use
> wordwrap()
> $message = wordwrap($message, 70);
>
> // Send
> $x = mail('kenhough at uklinux.net', 'My Subject', $message);
>
> echo $message.'<br>';
> if($x == TRUE) echo "TRUE".'<br>';
> if($x == FALSE) echo "FALSE".'<br>';
> ?>
>
> appears to send a message --- at least judging by the LED activity on
> my ADSL /router, but no messages appear in my mail box and 'TRUE' is
> echoed to the screen.
>
> What am I missing?
>
> Can annyone recomend a good Internet link on the subject?
>
>
> Ken Hough
>
> _______________________________________________
> Lancaster mailing list
> Lancaster at mailman.lug.org.uk
> https://mailman.lug.org.uk/mailman/listinfo/lancaster
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.lug.org.uk/pipermail/lancaster/attachments/20070628/9077fa4c/attachment-0001.html
More information about the Lancaster
mailing list