1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

E-Mailing

Discussion in 'PHP' started by MichaelLewis, Feb 23, 2009.

  1. #1
    I am trying to have my PHP code send an e-mail.

    My code, which doesn't work is:

    //======= SEND E-MAIL =================
    $mailTo = "michaelLewis@hotmail.com";
    $mailSubject = "ET Assignment.";
    $mailBody = "ET Assignment follows:";
    $mailBody = $EMailMsg;
    $mailHeaders = "From: http://www.mywebsite/\n";
    mail($mailTo, $mailSubject, $mailBody, $mailHeaders);

    Thanks for your help,
    Michael
     
    MichaelLewis, Feb 23, 2009 IP
  2. ebizaustralia

    ebizaustralia Peon

    Messages:
    91
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #2
    ebizaustralia, Feb 23, 2009 IP
  3. SmallPotatoes

    SmallPotatoes Peon

    Messages:
    1,321
    Likes Received:
    41
    Best Answers:
    0
    Trophy Points:
    0
    #3
    1. You don't explain what is meant by "doesn't work". What are the symptoms of it not working? Does the email arrive malformed? Do you get an error message? Does smoke start to rise from your monitor?

    2. You set $mailBody and then you replace it in the next line. That won't stop it from working but it isn't very useful.

    3. "http://www.mywebsite/" is not a valid email address. Many spam filters will drop your message, bless their hearts.

    4. You do not need to terminate the 4th argument to mail() with a newline.
     
    SmallPotatoes, Feb 24, 2009 IP
  4. MichaelLewis

    MichaelLewis Active Member

    Messages:
    36
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    93
    #4
    1- Nothing happens. E-Mail is not sent, no error message, successful end of job.
    2- About $mailBody" - I meant to combine the two - Thanks.
    3- I have tried with a valid e-mail address - no better; I have removed the $header param from mail(.....) - still no better.
    4- I need the ";" account more code follows it.

    Thanks & hope you've got more for me.
     
    MichaelLewis, Feb 25, 2009 IP
  5. mystxx

    mystxx Active Member

    Messages:
    39
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    91
    #5
    Usually this means there's a problem with the server - at least from my experience. I.e. something not set up right.
    Or for some reason spam filters are killing it on the receiving end. Maybe try some other account besides hotmail if you haven't already.
     
    mystxx, Feb 25, 2009 IP
  6. SmallPotatoes

    SmallPotatoes Peon

    Messages:
    1,321
    Likes Received:
    41
    Best Answers:
    0
    Trophy Points:
    0
    #6
    Huh? The newline is the \n in the $mailHeaders string. A semicolon is not a newline.

    Anyway, mystxx's tip is good. Don't use Hotmail to test this because its spam filter is fierce and capricious. And check phpinfo() to see whether mail is even set up in a plausibly viable way on your server. If all else fails, try using the PEAR MIME_Mail package with a known SMTP server (which your ISP or host may provide you with).
     
    SmallPotatoes, Feb 25, 2009 IP