Issue with Mail Function

Discussion in 'PHP' started by adamjblakey, Feb 16, 2010.

  1. #1
    Hi,

    I am using the following mail function which is working fine but when i use this to send to an @ntlworld account they do not get it. Is there anything i can change that i am missing?

    
    function email_member($to_email, $esubject, $to_name, $from_company, $from_email, $content){
    
    			# -=-=-=- MIME BOUNDARY
    			
    			$mime_boundary = "----$from_company----".md5(time());
    			
    			# -=-=-=- MAIL HEADERS
    			
    			$to = $to_email;
    
    			$subject = $esubject;
    			
    			$headers = "From: $from_company <$from_email>\n";
    			$headers .= "Reply-To: $from_company <$from_email>\n";
    			$headers .= "MIME-Version: 1.0\n";
    			$headers .= "Content-Type: multipart/alternative; boundary=\"$mime_boundary\"\n";
    			
    			# -=-=-=- TEXT EMAIL PART
    			
    			$message = "--$mime_boundary\n";
    			$message .= "Content-Type: text/plain; charset=UTF-8\n";
    			$message .= "Content-Transfer-Encoding: 8bit\n\n";
    					
    			# -=-=-=- HTML EMAIL PART
    			 
    			$message .= "--$mime_boundary\n";
    			$message .= "Content-Type: text/html; charset=UTF-8\n";
    			$message .= "Content-Transfer-Encoding: 8bit\n\n";
    			
    			$message .= "<html>\n";
    			$message .= "<body style=\"font-family:Tahoma, Geneva, sans-serif; font-size:11px; color:#333; line-height:18px;\">\n";
    			$message .= "Dear $to_name,\n\n";
    			$message .= "<br>\n";
    			$message .= "$content";
    
    				$message .= "<br>\n";
    			
    			$message .= "<br><span style='font-size:10px; color:#B9B8B8; line-height:12px;'><br><b>Email disclaimer</b><br>This email and its attachments may be confidential and are intended solely for the use of the individual to whom it is addressed. Any views or opinions expressed are solely those of the author and do not necessarily represent those of $from_company. If you are not the intended recipient of this email and its attachments, you must take no action based upon them, nor must you copy or show them to anyone. Please contact the sender if you believe you have received this email in error.</span>";
    			
    			$message .= "</body>\n";
    			$message .= "</html>\n";
    			   
    			# -=-=-=- FINAL BOUNDARY
    			
    			$message .= "--$mime_boundary--\n\n";
    			
    			# -=-=-=- SEND MAIL
    			
    			$mail_sent = @mail( $to, $subject, $message, $headers );
    }
    
    PHP:

     
    adamjblakey, Feb 16, 2010 IP
  2. danx10

    danx10 Peon

    Messages:
    1,179
    Likes Received:
    44
    Best Answers:
    2
    Trophy Points:
    0
    #2
    Have you checked the spam/junk folder?

    and are you sure your not validating the email anywhere? (if so post the code you use to validate, here).
     
    Last edited: Feb 16, 2010
    danx10, Feb 16, 2010 IP
  3. Marshton

    Marshton Peon

    Messages:
    109
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #3
    adding this to the end of the code:

     if ($mailsend == FALSE) {
    echo 'Something went wrong: <a href="http://php.net/manual/en/function.mail.php">PHP Mail</a>';
    } 
    PHP:
    It'll tell you if the problem is at your end, of it's a problem with @ntlworld
     
    Last edited: Feb 16, 2010
    Marshton, Feb 16, 2010 IP
  4. danx10

    danx10 Peon

    Messages:
    1,179
    Likes Received:
    44
    Best Answers:
    2
    Trophy Points:
    0
    #4
    @Marshton
    You have a typo in your code, you forgot to add the end quote, and semicolon.


    You can also do:

    function email_member($to_email, $esubject, $to_name, $from_company, $from_email, $content){
    
                # -=-=-=- MIME BOUNDARY
               
                $mime_boundary = "----$from_company----".md5(time());
               
                # -=-=-=- MAIL HEADERS
               
                $to = $to_email;
    
                $subject = $esubject;
               
                $headers = "From: $from_company <$from_email>\n";
                $headers .= "Reply-To: $from_company <$from_email>\n";
                $headers .= "MIME-Version: 1.0\n";
                $headers .= "Content-Type: multipart/alternative; boundary=\"$mime_boundary\"\n";
               
                # -=-=-=- TEXT EMAIL PART
               
                $message = "--$mime_boundary\n";
                $message .= "Content-Type: text/plain; charset=UTF-8\n";
                $message .= "Content-Transfer-Encoding: 8bit\n\n";
                       
                # -=-=-=- HTML EMAIL PART
                 
                $message .= "--$mime_boundary\n";
                $message .= "Content-Type: text/html; charset=UTF-8\n";
                $message .= "Content-Transfer-Encoding: 8bit\n\n";
               
                $message .= "<html>\n";
                $message .= "<body style=\"font-family:Tahoma, Geneva, sans-serif; font-size:11px; color:#333; line-height:18px;\">\n";
                $message .= "Dear $to_name,\n\n";
                $message .= "<br>\n";
                $message .= "$content";
    
                    $message .= "<br>\n";
               
                $message .= "<br><span style='font-size:10px; color:#B9B8B8; line-height:12px;'><br><b>Email disclaimer</b><br>This email and its attachments may be confidential and are intended solely for the use of the individual to whom it is addressed. Any views or opinions expressed are solely those of the author and do not necessarily represent those of $from_company. If you are not the intended recipient of this email and its attachments, you must take no action based upon them, nor must you copy or show them to anyone. Please contact the sender if you believe you have received this email in error.</span>";
               
                $message .= "</body>\n";
                $message .= "</html>\n";
                   
                # -=-=-=- FINAL BOUNDARY
               
                $message .= "--$mime_boundary--\n\n";
               
                # -=-=-=- SEND MAIL
               
                if(@mail( $to, $subject, $message, $headers )){
                return true;
                } else {
                return false;
                }
    }
    PHP:
    It will echo 1 if it sent.

    Which will distinguish if its php mail related or a problem on the other-side (recipient)
     
    danx10, Feb 16, 2010 IP
  5. Marshton

    Marshton Peon

    Messages:
    109
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Damn. Thats embarrasing.

    Thanks for the pointer!

    *Runs to a corner*
     
    Marshton, Feb 16, 2010 IP
  6. Izonedig

    Izonedig Member

    Messages:
    150
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    28
    #6
    Check my email functions, they may help you :)
    See link 1 in my sig, then go to label emails
     
    Izonedig, Feb 16, 2010 IP
  7. adamjblakey

    adamjblakey Active Member

    Messages:
    1,121
    Likes Received:
    10
    Best Answers:
    0
    Trophy Points:
    80
    #7
    It is definitely not on the server side as i have tried to several other email address including yahoo, gmail and hotmail and goes through fine. On this ntl email address though nothing comes through but does not go in the spam filter either.
     
    adamjblakey, Feb 17, 2010 IP
  8. Marshton

    Marshton Peon

    Messages:
    109
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #8
    Yeah, but have you actually tried the code that danx10 suggested...?
     
    Marshton, Feb 17, 2010 IP