Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New to the CF scene
    Join Date
    Jun 2011
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    php mailer with html

    Hi!
    I need some help... I have this php email, It works fine (very simple and clean): when somebody sends me and email from my website, I receive the his info and he receives an autoresponder email with the mail confirmation.

    Now, I'd love to send the auto responder as an html email, with logo image in the body of the email.

    Could you help me? I tried everything I found on the web, but it doesnt work!

    this is the code I have:

    PHP Code:

    <?php
        
    function anti_spam($str) {
            
    $str strtolower($str);
            
    $str trim($str);
            if (
    $str == || $str == '2' || $str == 'two') {
                return 
    TRUE;
            } else {
                return 
    FALSE;
            }
        }
              if(isset(
    $_POST['submit'])) {
              
    error_reporting(E_NOTICE);
              function 
    valid_email($str)
              {
              return ( ! 
    preg_match("/^([a-z0-9\+_\-]+)(\.[a-z0-9\+_\-]+)*@([a-z0-9\-]+\.)+[a-z]{2,6}$/ix"$str)) ? FALSE TRUE;
                 }
              if(
    $_POST['name']!='' && anti_spam($_POST['antispam'])==TRUE &&  $_POST['email']!='' && valid_email($_POST['email'])==TRUE && strlen($_POST['comment'])>1)
              {
            
    $to preg_replace("([\r\n])"""$_POST['receiver']);
            
    $from preg_replace("([\r\n])"""$_POST['name']);
            
    $subject $_POST['subject'];
            
    $email $_POST['email'];
            
    $telefono $_POST['telefono'];
            
    $comment $_POST['comment'];
            
    $time date('j F, Y g:i a'time());
            
            
    $message "Da: $from  \r\nData Invio: $time \r\nTelefono: $telefono \r\nOggetto: $subject \r\nMessaggio: $comment";
                 
    $autoTo $_POST['email'];
    $autoreply "Salve $from,\n\rQuesto  un risponditore automatico.\n\rAbbiamo ricevuto la sua richiesta.\n\rLa contatteremo quanto prima!\n\rGrazie!\n\r";  //change this to your message

    mail($autoTo"Richiesta inoltrata con successo!"$autoreply'From: myemail@email.com');

                 
                  
    $match "/(bcc:|cc:|content\-type:)/i";
                    if (
    preg_match($match$to) ||
                        
    preg_match($match$from) ||
                        
    preg_match($match$message) || preg_match($match$subject)) 
                
                    {
                      die(
    "Header injection detected.");
                    }
                  
    $headers "Da: \"".$_POST['name']."\" <".$_POST['email'].">\n";
                     
    $headers .= "Rispondi a: ".$_POST['email']."\r\n";
                 
            if(
    mail($to$subject$message$headers))
                  {
                      echo 
    1//SUCCESS
                  
    }
                  else {
                      echo 
    2//FAILURE - server failure
                  
    }
              }
              else {
                 echo 
    3//FAILURE - not valid email

              
    }
              }else{
                 die(
    "Direct access not allowed!");
               }
    ?>


    Thank you!!!

  • #2
    Regular Coder
    Join Date
    Jul 2010
    Posts
    271
    Thanks
    3
    Thanked 40 Times in 40 Posts
    For sending html with email.

    PHP Code:
    <?
    $from 
    "email from";
     
    $to "sent to";
     
    $subject "test";
     
    $body "<html><body><font color=red>This is a test</font></body></html>";
     
     require_once(
    "class.phpmailer.php");
    $mail = new PHPMailer();
    $mail->IsSMTP(); // telling the class to use SMTP
    $mail->IsHTML(true);
    $mail->SMTPAuth true;
    $mail->Username "your SMTP username"
    $mail->Password "your SMTP password"
    $mail->Host "SMTP server"// 
    $mail->From $from;
    $mail->AddAddress($to);
    $mail->Subject $subject;
    $mail->Body $body;
    if(!
    $mail->Send()) {
      echo 
    'Message was not sent.';
      echo 
    'Mailer error: ' $mail->ErrorInfo;
    } else {
    echo 
    'Message has been sent successfully';
        }

    ?>
    class.phpmailer.php can be gotten here: http://www.phpclasses.org/package/26...s-for-PHP.html
    If you can't stand behind your troops, feel free to stand in front of them
    Semper Fidelis

  • #3
    New to the CF scene
    Join Date
    Jun 2011
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thank you so much for your reply, but where do I insert this code you sent me?


  •  

    Tags for this Thread

    Posting Permissions

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