Anything wrong with my SendMail code?

Discussion in 'PHP' started by TheSyndicate, Feb 16, 2009.

  1. #1
    My mail does not work is there anything wrong with my code i missed?

    function sendHTMLmail($fromid,$to,$subject,$message)
    {
     include_once("mailer.php");
     $mail = new PHPMailer();
     $mail->IsMail();
     $mail->Host     = "localhost"; // SMTP servers
     $mail->From     = $fromid;
     $mail->FromName =  $fromid;
     $mail->IsHTML(true); 
     $mail->AddAddress($to,$to); 
     $mail->Subject  = $subject;
     $mail->Body     = $message;
     $mail->AltBody  =  "Please enable HTML to read this";
     $mail->Send();
    PHP:
     
    TheSyndicate, Feb 16, 2009 IP
  2. ranacseruet

    ranacseruet Peon

    Messages:
    302
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #2
    is your mail.php written correctly?
     
    ranacseruet, Feb 16, 2009 IP
  3. TheSyndicate

    TheSyndicate Prominent Member

    Messages:
    5,410
    Likes Received:
    289
    Best Answers:
    0
    Trophy Points:
    365
    #3
    hehe good question. I better check that one as well i guess. But this code is ok?
     
    TheSyndicate, Feb 16, 2009 IP
  4. m0nkeymafia

    m0nkeymafia Well-Known Member

    Messages:
    399
    Likes Received:
    12
    Best Answers:
    0
    Trophy Points:
    125
    #4
    Are you using the PHP Mailer script?
    What error do you get?

    If it isnt working I would suggest commenting out that entire block and using PHP's Mail and not mailer.php.
    If that works then slowly start introducing mailer.php and its features until you find out where it falls over
     
    m0nkeymafia, Feb 16, 2009 IP
  5. LittleJonSupportSite

    LittleJonSupportSite Peon

    Messages:
    386
    Likes Received:
    20
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Code looks good. Post mailer.php


    Also I would add some security to this before going live.

    Prevent the spammers from hijacking your mailer.

    Classic case would be to add bcc headers or to replace the to/from etc etc.


    Also add in a dnsbl check to block them right from go.
     
    LittleJonSupportSite, Feb 16, 2009 IP
  6. TheSyndicate

    TheSyndicate Prominent Member

    Messages:
    5,410
    Likes Received:
    289
    Best Answers:
    0
    Trophy Points:
    365
    #6
    Support you have any sample of that?
     
    TheSyndicate, Feb 16, 2009 IP