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

有帮助吗?

解决方案

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.

其他提示

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.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top