Pergunta

I have a contact form, with mail() function. For a long time it worked correctly. Suddenly now it doesn't work. I have checked, but all is correct. But if I delete the sender parameter, it works, with sender parameters it doesn't work:

mail($destinatario_1,$oggetto_1,$messaggio_1,'');

WORKS

Instead:

mail($destinatario_1,$oggetto_1,$messaggio_1,'From: "My Name" <thisisanexample@gmail.com> \r\n');

Thanks

Foi útil?

Solução

Try this instead:

mail($destinatario_1, $oggetto_1, $messaggio_1, "From: My Name <thisisanexample@gmail.com>");

Note that I leave our the \r\n which should just be \n on most servers and must be in double quotes not single quotes, and "My Name" shouldn't be in quotes.

Outras dicas

Mail servers can be configured to not accept mail when certain information is set. The PHP mail() function more or less directly talks to the local mail server and passes the mail to it. Whether the mail server accepts it or not is not really part of the communication and cannot be detected by a PHP script.

Consult your web hosting company to find out if there are any restrictions.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top