- This topic is empty.
July 10, 2012 at 5:15 am #38850Metal_headMember
I tried the following code with my email as $to but I got the message from the else part.
Sending email using PHP
$to = "[email protected]";
$subject = "This is subject";
$message = "This is simple text message.";
$header = "From:[email protected] rn";
$retval = mail ($to,$subject,$message,$header);
if( $retval == true )
echo "Message sent successfully...";
echo "Message could not be sent...";
Can anyone tell me the corrections?
What should be the config of the [mail function] in php.ini for Windows? How to change it on the server where the site is hosted? Please refer the first link for this config.
MHJuly 10, 2012 at 5:53 am #105796HoughtonAParticipant
I don’t know much about php for Windows, but this might be relevant. Hope that helps!July 19, 2012 at 2:04 pm #106429irish1381Member
Couple of questions:
1.) Are you trying to send via SMTP or PHP native mail() function?
2.) Do you have an SMTP server setup on your windows box?
Also, you’re not providing the proper mail headers. You need:
– content-type / charset
all which need to new line breaks for the native mail function. ie “rn”.July 19, 2012 at 4:58 pm #106442paintba11er89Member
Not sure if it matters, but there should be a space after the “From:” in your $header variable, and there should be no space before the rn. Also, keep in mind that a local server is not going to be able to send out mail (at least without special set up or additional software). If you want to test this legitimately, make sure you’re running it on a live server.July 20, 2012 at 11:08 am #106475BlackhawksoMember
Some times the mail() php function can be switched off as default by your hosting company in the php.ini file. One thing you can try to do is put a php.ini file in the same directory as the script and make sure that the mail() function is switched on in it. This sometimes might not work if the hosting company have set the server up to ignore other php.ini files.July 20, 2012 at 11:11 am #106476
- The forum ‘Back End’ is closed to new topics and replies.