Problems PHP email function

Ask a Question related to Macromedia Dynamic HTML, Design and Development.

  1. #1

    Default Problems PHP email function

    I am trying to create a page that can send emails using PHP. But i keep
    getting the following error:

    Warning: mail() [function.mail]: "sendmail_from" not set in php.ini or custom
    "From:" header missing

    I am running these off of my computer on an apache test server on my windows
    os. My php.ini is set up as:

    [mail function]
    ; For Win32 only.
    SMTP = smtp.aol.com
    smtp_port = 25

    ; For Win32 only.
    ;sendmail_from = [email]myemailaddress@aol.com[/email] (not I used my actual email address)

    and my script is:

    <?php
    echo "<p>Thank you, <b>$_POST[name]</b>, for your message!</p>";
    echo "<p>Your e-mail address is: <b>$_POST[email]</b>.</p>";
    echo "<p>Your message was:<br>";
    echo "$_POST[message] </p>";
    //start building the mail string
    $msg = "Name: $_POST[name]\r\n";
    $msg .= "E-Mail: $_POST[email]\r\n";
    $msg .= "Message: $_POST[message]\r\n";
    //set up the mail
    $recipient = "you@yourdomain.com";
    $subject = "Form Submission Results";
    $mailheaders = "From: My Web Site <gamespy007@aol.com> \r\n";
    $mailheaders .= "Reply-To: $_POST[email]";
    //send the mail
    mail($recipient, $subject, $msg, $mailheaders);
    ?>

    Could anyone tell me if they see anything wrong and what I should do to
    correct it. Thanks.




    Gamespy007 Guest

  2. Similar Questions and Discussions

    1. Email Problems
      I have emails that are getting moved to the undelivered folder. The only thing I can determine that they have in common is a long list of users in...
    2. Email from website function not working
      I used Publisher to create a website in which I want to be able for users to complete a form, press the submit button and the site will then email...
    3. #12335 [Com]: mail() function returns false but the email was sent.
      ID: 12335 Comment by: liliana at civc dot inf dot cu Reported By: sascha dot winkler at ks dot sel dot alcatel dot de...
    4. Email problems with Extras.
      Hi there. I'm in the process of creating a projector which requires the end user to email an external cast file back to me. I've tried several of...
    5. problems with Apple email
      hello. i am using a lime green iMac with Mac OS 10.2 installed, and am having a problem with my Mail program. The inbox refuses to display my new...
  3. #2

    Default Re: Problems PHP email function

    Your send_mail from line is commented out, you need to delete the initial
    semi-colon.


    Gamespy007 wrote:
    > I am trying to create a page that can send emails using PHP. But i
    > keep getting the following error:
    >
    > Warning: mail() [function.mail]: "sendmail_from" not set in php.ini
    > or custom "From:" header missing
    >
    > I am running these off of my computer on an apache test server on my
    > windows os. My php.ini is set up as:
    >
    > [mail function]
    > ; For Win32 only.
    > SMTP = smtp.aol.com
    > smtp_port = 25
    >
    > ; For Win32 only.
    > ;sendmail_from = [email]myemailaddress@aol.com[/email] (not I used my actual email
    > address)
    >
    > and my script is:
    >
    > <?php
    > echo "<p>Thank you, <b>$_POST[name]</b>, for your message!</p>";
    > echo "<p>Your e-mail address is: <b>$_POST[email]</b>.</p>";
    > echo "<p>Your message was:<br>";
    > echo "$_POST[message] </p>";
    > //start building the mail string
    > $msg = "Name: $_POST[name]\r\n";
    > $msg .= "E-Mail: $_POST[email]\r\n";
    > $msg .= "Message: $_POST[message]\r\n";
    > //set up the mail
    > $recipient = "you@yourdomain.com";
    > $subject = "Form Submission Results";
    > $mailheaders = "From: My Web Site <gamespy007@aol.com> \r\n";
    > $mailheaders .= "Reply-To: $_POST[email]";
    > //send the mail
    > mail($recipient, $subject, $msg, $mailheaders);
    >>
    >
    > Could anyone tell me if they see anything wrong and what I should do
    > to correct it. Thanks.

    rob::db Guest

  4. #3

    Default Re: Problems PHP email function

    I removed the semi-colon and am still getting the same error. The php.ini
    looks like:

    [mail function]

    ; For Win32 only.
    SMTP = smtp.aol.com
    smtp_port = 25

    ; For Win32 only.
    sendmail_from = [email]myemailaddress@aol.com[/email] (not I used my actual email address)

    And the php script is still the same as above. Do you see anything else wrong
    with my code.

    Gamespy007 Guest

  5. #4

    Default Re: Problems PHP email function

    It may be that your setup won't let you connect to a remote email server, or
    more likely, the remote server won't let you connect to it. Not sure
    though...


    Gamespy007 wrote:
    > I removed the semi-colon and am still getting the same error. The
    > php.ini looks like:
    >
    > [mail function]
    >
    > ; For Win32 only.
    > SMTP = smtp.aol.com
    > smtp_port = 25
    >
    > ; For Win32 only.
    > sendmail_from = [email]myemailaddress@aol.com[/email] (not I used my actual email
    > address)
    >
    > And the php script is still the same as above. Do you see anything
    > else wrong with my code.

    rob::db Guest

  6. #5

    Default Re: Problems PHP email function

    I think your right. After I took out the semi-colon, I got this error message:

    Warning: mail() [function.mail]: Failed to connect to mailserver at
    "smtp.localhost" port 25, verify your "SMTP" and "smtp_port" setting in php.ini
    or use ini_set()

    I tried to change my smtp from aol to localhost, But am still getting the same
    error. I am using an apache server on my home desktop as a test server. Is
    there anyway I can use it for my smtp?

    Gamespy007 Guest

  7. #6

    Default Re: Problems PHP email function

    Well, if you install a Sendmail server or something like it on your testing
    server, then you can send email from it (Apache is just a web server, it
    doesn't deal with email). That's a massive amount of trouble though. It's
    easier just to leave testing the mail functions until the site's on a proper
    live host.



    Gamespy007 wrote:
    > I think your right. After I took out the semi-colon, I got this
    > error message:
    >
    > Warning: mail() [function.mail]: Failed to connect to mailserver at
    > "smtp.localhost" port 25, verify your "SMTP" and "smtp_port" setting
    > in php.ini or use ini_set()
    >
    > I tried to change my smtp from aol to localhost, But am still
    > getting the same error. I am using an apache server on my home
    > desktop as a test server. Is there anyway I can use it for my smtp?

    rob::db Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139