Re: Mail() function [message #180607 is a reply to message #180605] |
Wed, 06 March 2013 15:37 |
The Natural Philosoph
Messages: 993 Registered: September 2010
Karma:
|
Senior Member |
|
|
On 06/03/13 14:46, Rita Ferreira wrote:
> Hi,
> I'm new at PHP and I'm facing problems with the mail() function.
> I'm trying to send an email from a form and to do it I'm using mail() function but gmail assume it like spam.
>
> I have read lots of similar problems in internet but I couldn't find a solution.
>
>
> <?php
>
> if (isset($_REQUEST['email']))
> {
> $nome = $_REQUEST['nome'] ;
> $telefone = $_REQUEST['telefone'] ;
> $email = $_REQUEST['email'] ;
> $message = $_REQUEST['mensagem'] ;
> $header .= "Reply-To:".$nome." <".$email.">\r\n";
> $header .= "Return-Path: ".$nome." <".$email.">\r\n";
> $header .= "From: ".$nome." <".$email.">\r\n";
> $header .= "Organization: MyOrganization\r\n";
> $header .= "Content-Type: text/plain\r\n";
>
> mail("XXXXX(at)gmail(dot)com", "My message", $message, $header);
>
> header ('Location:index_teste.php?area=contactenos');
> }
>
>
> Can you please help me trying to find what I do have wrong here?
> Any help will be welcome.
> Thanks.
>
the line the works for me is this
mail($email, $subject, $message, $headers, "-f ".$return_path );
Note the -f argument to set a valid sender address, otherwise mail
relays can and will reject the message.
In my case $return_path contains 'webmaster(at)mysite(dot)com' etc etc.
Also depending on the server you are posting from, the mail relay
subsystem may not be set up correctly.
--
Ineptocracy
(in-ep-toc’-ra-cy) – a system of government where the least capable to
lead are elected by the least capable of producing, and where the
members of society least likely to sustain themselves or succeed, are
rewarded with goods and services paid for by the confiscated wealth of a
diminishing number of producers.
|
|
|