Having Problems with SIMPLE mail() function - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

Having Problems with SIMPLE mail() function

belpernabelperna Posts: 1Member
Hi,

I am trying to learn php. My web host has version 4.1.2 running on their webserver.

I have a VERY simple script that I CANNOT get to work and the webhost support keeps telling me that all their other clients can get the mail function to work just fine and that the problem is in my code. I have simplified it down to just 3 lines of code, and STILL it will not work.
Am I missing something with the syntax? I have a php file that only has the following in it:

<?php
$mysubject = "TEST EMAIL FROM MSGBOARD";
$myemail = "[email protected]";
$mybody = "This is a test email to see if it works";
mail($myemail, $mysubject, $mybody);
?>

Can someone take a peek and let me know if it's something obvious.

Thanks

Comments

  • sleepydannysleepydanny Posts: 1Member
    Its really strange, it should work for you, try making a form and when the submit button is clicked the mail is sent, or try to change the email address to a different address.
  • mainewoodsmainewoods Posts: 18Member
    You might want to try this: surround your variables in your mail function with double quotes like this:
    mail("$myemail", "$mysubject", "$mybody");

    Hope this helps

    : Hi,
    :
    : I am trying to learn php. My web host has version 4.1.2 running on their webserver.
    :
    : I have a VERY simple script that I CANNOT get to work and the webhost support keeps telling me that all their other clients can get the mail function to work just fine and that the problem is in my code. I have simplified it down to just 3 lines of code, and STILL it will not work.
    : Am I missing something with the syntax? I have a php file that only has the following in it:
    :
    : <?php
    : $mysubject = "TEST EMAIL FROM MSGBOARD";
    : $myemail = "[email protected]";
    : $mybody = "This is a test email to see if it works";
    : mail($myemail, $mysubject, $mybody);
    : ?>
    :
    : Can someone take a peek and let me know if it's something obvious.
    :
    : Thanks
    :

  • Virtua KnightVirtua Knight Posts: 78Member
    : You might want to try this: surround your variables in your mail function with double quotes like this:
    : mail("$myemail", "$mysubject", "$mybody");
    :
    : Hope this helps
    :
    : : Hi,
    : :
    : : I am trying to learn php. My web host has version 4.1.2 running on their webserver.
    : :
    : : I have a VERY simple script that I CANNOT get to work and the webhost support keeps telling me that all their other clients can get the mail function to work just fine and that the problem is in my code. I have simplified it down to just 3 lines of code, and STILL it will not work.
    : : Am I missing something with the syntax? I have a php file that only has the following in it:
    : :
    : : <?php
    : : $mysubject = "TEST EMAIL FROM MSGBOARD";
    : : $myemail = "[email protected]";
    : : $mybody = "This is a test email to see if it works";
    : : mail($myemail, $mysubject, $mybody);
    : : ?>
    : :
    : : Can someone take a peek and let me know if it's something obvious.
    : :
    : : Thanks
    : :
    :
    :

    When you suggest something like that, a reason would probably be a good thing to include.

    http://www.ocdn.fairmount.nu/ - Omnisoft - Quality webmaster scripts and services.

  • Virtua KnightVirtua Knight Posts: 78Member
    Your host is BSing you; once my previous one told me that when he viewed my site, only one ad window popped up on the initial view, and none on the reload. That didn't change the fact that there were FOUR that popped up whenever I asked someone to check for me.

    : Hi,
    :
    : I am trying to learn php. My web host has version 4.1.2 running on their webserver.
    :
    : I have a VERY simple script that I CANNOT get to work and the webhost support keeps telling me that all their other clients can get the mail function to work just fine and that the problem is in my code. I have simplified it down to just 3 lines of code, and STILL it will not work.
    : Am I missing something with the syntax? I have a php file that only has the following in it:
    :
    : <?php
    : $mysubject = "TEST EMAIL FROM MSGBOARD";
    : $myemail = "[email protected]";
    : $mybody = "This is a test email to see if it works";
    : mail($myemail, $mysubject, $mybody);
    : ?>
    :
    : Can someone take a peek and let me know if it's something obvious.
    :
    : Thanks
    :


    http://www.ocdn.fairmount.nu/ - Omnisoft - Quality webmaster scripts and services.

  • mainewoodsmainewoods Posts: 18Member
    The reason I suggested what I did is I have a mail script running that is almost identical to yours except that I surround the variables with the quotes. The more I think about it though, the more I think that the quotes I use should not be nessary in this application. As written your mail program should be working fine. You should check for some simple things though. Like have you made sure the php itself is working by creating the simplest possible php file by using just one print(); statement? Also some servers might require you to use different extensions like .php3 or .php4. Could some filtering software on your mail client be stopping you from recieving the email at the specified email address? Other than those possibilities I would say that it must be a problem with your web host because I believe your code is perfectly valid as written.



    : Hi,
    :
    : I am trying to learn php. My web host has version 4.1.2 running on their webserver.
    :
    : I have a VERY simple script that I CANNOT get to work and the webhost support keeps telling me that all their other clients can get the mail function to work just fine and that the problem is in my code. I have simplified it down to just 3 lines of code, and STILL it will not work.
    : Am I missing something with the syntax? I have a php file that only has the following in it:
    :
    : <?php
    : $mysubject = "TEST EMAIL FROM MSGBOARD";
    : $myemail = "[email protected]";
    : $mybody = "This is a test email to see if it works";
    : mail($myemail, $mysubject, $mybody);
    : ?>
    :
    : Can someone take a peek and let me know if it's something obvious.
    :
    : Thanks
    :

Sign In or Register to comment.