Closed Thread
Results 1 to 7 of 7

Thread: PHP Sendmail

  1. #1
    memres25 is offline x10Hosting Member memres25 is an unknown quantity at this point
    Join Date
    Jul 2011
    Posts
    3

    PHP Sendmail

    Hello. It seems that the below code doesn't send the mails.

    $today = date('d.m.Y');
    $now = date('H:i');
    $ip = getenv('REMOTE_ADDR');
    $agent = getenv('HTTP_USER_AGENT');
    $referer = getenv('HTTP_REFERER');
    $name = $_REQUEST['name'];
    $email = $_REQUEST['email'];
    $subject = $_REQUEST['subject'];
    $message = $_REQUEST['message'];
    $to = "my@email.com";
    $from = "From: $name <$email>";
    $from2 = "From: Me <$to>";
    $content = "Content for me";
    $content2 = "Content for sender";
    if ($email && $message)
    mail($to, $subject, $content, $from); // to me
    mail($email, $subject2, $content2, $from2); // to sender

    I'll appreciate your help. Thanks.

  2. #2
    Skizzerz's Avatar
    Skizzerz is offline Contributors Skizzerz will become famous soon enough
    Join Date
    Nov 2007
    Location
    Texas
    Posts
    2,153

    Re: PHP Sendmail

    From: must be a valid email account registered on your cPanel

  3. #3
    stpvoice's Avatar
    stpvoice is offline Community Support Rep stpvoice has a brilliant futurestpvoice has a brilliant futurestpvoice has a brilliant future
    Join Date
    Dec 2008
    Location
    United Kingdom
    Posts
    5,939

    Re: PHP Sendmail

    Hello,

    The content-type header must be present and set to text/plain for php mail to work. Here's a copy of a script I know to work on all free servers. Maybe you can adapt it to what you need:
    Code:
    <?php
    $to  = 'them@example.com' . ', ';
    $subject = 'Subject here';
    $message = '
    Enter message body
    ';
    $headers  = 'MIME-Version: 1.0' . "\r\n";
    $headers .= 'Content-type: text/plain; charset=iso-8859-1' . "\r\n";
    $headers .= 'To: First Last <them@example.com>' . "\r\n";
    $headers .= 'From: First Last <you@example.com>' . "\r\n";
    if (mail($to,$subject,$message,$headers) ) {
           echo "email sent";
        } else {
           echo "email couldn't be sent";
    };
    ?>
    Also, you need to ensure any messages are sent from an address that actually exists in your cPanel.
    Last edited by stpvoice; 07-10-2011 at 11:32 AM.


  4. #4
    memres25 is offline x10Hosting Member memres25 is an unknown quantity at this point
    Join Date
    Jul 2011
    Posts
    3

    Re: PHP Sendmail

    I use Google Apps for my domain's email accounts. Am I able to use sendmail via my Google email account?

  5. #5
    descalzo's Avatar
    descalzo is offline Grim Squeaker descalzo has a brilliant futuredescalzo has a brilliant futuredescalzo has a brilliant future
    Join Date
    Jul 2009
    Location
    Ankh-Morpork
    Posts
    7,635

    Re: PHP Sendmail

    Get PHPMailer , http://phpmailer.worxware.com/ , and use SMTP ( via ssl and port 465 ) to send it through your Google Apps account.
    Nothing is always absolutely so.

  6. #6
    memres25 is offline x10Hosting Member memres25 is an unknown quantity at this point
    Join Date
    Jul 2011
    Posts
    3

    Thumbs up Re: PHP Sendmail

    Thank you in advance for whom try to help me.

    I solve the matter by changing the $to variable from my local email address to a remote one.

  7. #7
    stpvoice's Avatar
    stpvoice is offline Community Support Rep stpvoice has a brilliant futurestpvoice has a brilliant futurestpvoice has a brilliant future
    Join Date
    Dec 2008
    Location
    United Kingdom
    Posts
    5,939

    Re: PHP Sendmail

    Resolved; closed.


Closed Thread

Similar Threads

  1. Sendmail is down
    By rog1121 in forum Free Hosting
    Replies: 1
    Last Post: 04-26-2011, 06:17 PM
  2. sendmail
    By AlphaHub in forum Free Hosting
    Replies: 4
    Last Post: 02-25-2008, 07:12 AM
  3. sendmail
    By AlphaHub in forum Free Hosting
    Replies: 1
    Last Post: 02-22-2008, 01:14 AM
  4. Sendmail
    By screamo in forum Soporte
    Replies: 6
    Last Post: 01-05-2008, 08:17 PM
  5. Perl Sendmail Problem -- sendmail config
    By adrenlinerush in forum Free Hosting
    Replies: 4
    Last Post: 12-06-2007, 09:50 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
x10hosting free hosting for the masses
dedicated servers