-
☆ A M B ☆
- 711 Posts
Hi,
The correct way to send email with just a php file is like this:
<?php
$to = "[email protected]";
$subject = "Test mail";
$message = "Hello! This is a simple email message.";
$from = "[email protected]";
$headers = "From: $from";
mail($to,$subject,$message,$headers);
echo "Mail Sent.";
?>
Could you try this and let me know if you still get the 500 error which is warning about no from address being set.
Thanks
Hi,
That message came through just fine.
Does that mean you know what the problem is?
-
☆ A M B ☆
- 711 Posts
Yep,
If I remember right you should be setting a from field i.e. on the contact form on Onesmarthost is:
[!eForm? &formid=`ContactForm` &from=`[+email+]` &subject=`[+subject+]` &to=`[email protected]` &ccsender=`1` &tpl=`ContactForm` &report=`ContactFormReport` &vericode=`1` &invalidClass=`invalidValue` &thankyou=`ContactFormThanks` &requiredClass=`requiredValue` &cssStyle=`ContactStyles`!]
[+email+] is picked up from the form which the user submitted and set’s their email as the from address for the email, some hosting providers will prevent you from sending email this way so you may have to manually set the from field address like:
[!eForm? &formid=`ContactForm` &from=`[email protected]` &subject=`[+subject+]` &to=`[email protected]` &ccsender=`1` &tpl=`ContactForm` &report=`ContactFormReport` &vericode=`1` &invalidClass=`invalidValue` &thankyou=`ContactFormThanks` &requiredClass=`requiredValue` &cssStyle=`ContactStyles`!]
Hope that helps
Aaron
-
☆ A M B ☆
- 711 Posts
I forgot to mention one more thing, is the email From Address valid for that server / domain?
Some hosts will restrict email going out if the from address is not the same as the domainname.
Aaron
oops. Amended that, and even created a new email account - but still the extact same error message.
I did contact my hosts, but they will not get invovled with coding issues as they call it.
It works fine on all linux servers on the same host, just not IIS7
-
☆ A M B ☆
- 711 Posts
Thats not very good of them, are you able to create a php file like my example above and send mail that way on the IIS7 server, if this works then the server works fine and we have to look closer at MODx and eForm.
However if the php example does not work on your IIS7 server then you would need to find out from your web host what the correct method is to send email via PHP.
Some hosting providers require that you authenticate with the server first before sending email.
Aaron