www.webdeveloper.com
Results 1 to 13 of 13

Thread: Sending EMAIL

Hybrid View

  1. #1
    Join Date
    Aug 2013
    Posts
    40

    Sending EMAIL

    Hi All,

    I tried to make a PHP script which used to send the mails to all the clients for the i thought first to make a dummy scirpt, But its fail during sending the mail. Below is a error message

    Warning: mail(): SMTP server response: 530 5.7.1 Client was not authenticated in C:\inetpub\wwwroot\dummy\email\email_script.php on line 10

    I don't know what authentication its need. Please help me to overcome from this problem.

    Below is my php script.

    Code:
    <?php
    
    $from="testturnover@abc.com";
    $email=$_POST['email'];
    $subject=$_POST['subject'];
    
    $message=$_POST['message'];
    
    
    mail($email, $subject, $message,"From:".$from);
    
    print "email has been sent : </br> $email</br>$subject</br>$message</br>";
    ?>
    Please let me know if something which i need to be change

    Thanks in advance

  2. #2
    Join Date
    Sep 2008
    Location
    Akron, OH
    Posts
    1,129
    Are you working on localhost? My guess is that you don't have a proper SMTP server configured for your localhost.
    I'm always up for networking with fellow web professionals. Connect with me on LinkedIn if you like!

  3. #3
    Join Date
    Aug 2013
    Posts
    40
    No basically i am using my company Email server address.

  4. #4
    Join Date
    Nov 2013
    Posts
    33
    try using the fifth parameter
    Code:
    mail($email, $subject, $message,"From:".$from, "-f$from");

  5. #5
    Join Date
    Aug 2013
    Posts
    40
    Same warning message after amedements

    Warning: mail(): SMTP server response: 530 5.7.1 Client was not authenticated in C:\inetpub\wwwroot\dummy\email\email_script.php on line 11
    email has been sent :

  6. #6
    Join Date
    Nov 2013
    Posts
    33
    try this, with more robust headers
    PHP Code:
    $from"testturnover@abc.com"//make sure that this is a real email
    $email"some_test_email@gmail.com";
    $subject"Php mail test";

    $message"Some random stuff";

    $header "From: {$from}\r\n";
    $header .= "Reply-To: {$email}\r\n";
    $header .= "Return-path: " $email;


    mail$email,  $subject$message$header"-f{$from}");

    print 
    "email has been sent : </br> $email</br>$subject</br>$message</br>"
    hopefully this will work for you.

  7. #7
    Join Date
    Mar 2013
    Location
    Iasi, Romania
    Posts
    53
    You need to authenticate in order to send emails.
    Why don't you use SMTP Mailer class?

    Here is an example using that:
    PHP Code:
       $subject    'Subject';
       
    $headers   'Headers';


       
    $content          "your content";
       
    $from_name      'sender\'s name';
       
    $from               'sender\'s email';
       
    $mail                = new PHPMailer();
       
    $mail->IsSMTP(); // telling the class to use SMTP
       
    $mail->Host                    "smtp.gmail.com";
       
    $mail->Port                    587;
       
    $mail->SMTPAuth                true;
       
    $mail->SMTPSecure              "tls";
       
    $mail->Username                "some email address for authentication";
       
    $mail->Password                "the password for that email address";
       
    $mail->FromName                $from_name;
       
    $mail->From                    $from;
       
    $mail->AddAddress('email of receiver','name of the receiver');
       
    $mail->Subject                $subject;
       
    $mail->MsgHTML($content);
       
    $result                        $mail->Send(); 
    Last edited by ssdog; 12-05-2013 at 10:18 AM.
    I'm sorry I keep looking at your chest while you're talking. It's just so beautiful. What is it, oak?

  8. #8
    Join Date
    Aug 2013
    Posts
    40
    Now i am getting the mails, But the mails is clearly in the plain text format below is the output of a mail



    First Name : Rohit

    Last Name: kapoor

    Comments : xyz



    I want some formatting on the outgoing mails, Can it will be possible like (If I bold [First Name, Last Name]) so it looks more good



    Below is the code..
    Code:
    $from="some@abc.com";
    $email="Rohit@xyz.com";
    $subject="You are registered on $date";
    $message='Fist Name : '.$First."\n"
                       .'Last Name : '.$last."\n"
                       .'Comments : '.$comments."\n"; 
     
    mail($email, $subject, $message,"From:".$from, "-f$from");
    Thanks in advance

  9. #9
    Join Date
    Aug 2013
    Posts
    40
    Its worked for me there was a problem in my SMTP address, and i have changed it and everything is working for me

  10. #10
    Join Date
    Nov 2013
    Posts
    33
    use headers
    PHP Code:
    $first 'firstname';
    $last 'lastname';
    $comment 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam eget tempus leo. Suspendisse quis purus vitae nunc ultricies sodales. Sed tempus justo placerat consectetur cursus.';

    $from"testturnover@example.com"//make sure that this is a real email 
    $email"some_test_email@gmail.com"
    $subject"Php mail test"

    $message"<html>
    <head>
      <title>Message From us</title>
    </head>
    <body>
      <p>Hi there 
    {$First} {$last} !</p>
      <p>
    {$comment}</p>
    </body>
    </html>"


    $header 'MIME-Version: 1.0' "\r\n";
    $header .= 'Content-type: text/html; charset=iso-8859-1' "\r\n";
    $header .= "From: {$from}\r\n"
    $header .= "Reply-To: {$email}\r\n"
    $header .= "Return-path: " $email


    mail$email,  $subject$message$header"-f{$from}"); 

    print 
    "email has been sent : </br> $email</br>$subject</br>$message</br>"

  11. #11
    Join Date
    Aug 2013
    Posts
    40
    Thanks for a reply
    But Why the font tag is not working

    HTML Code:
    						$message ="<html>
    								   <body>
    								   <hr>
    								   
    								   <p> <strong>[B]<font color ='grey'>[/B]First</strong> => {$first}</p>
    								   <p> <strong>Last </strong> => {$last}</p>
    								   <p> <strong>Comments </strong>  => {$shift_comments}</p>
    								   <hr>
    								   </body>
    								   </html>";
    								   
    						$header = 'MIME-Version: 1.0' . "\r\n";
    						$header .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";			
    						$header .= "From: {$from}\r\n"; 
    						$header .= "Reply-To: {$to}\r\n"; 
    						$header .= "Return-path: " . $to; 
    	
    						mail( $to,  $subject, $message, $header, "-f{$from}"); 
    	   

  12. #12
    Join Date
    Nov 2013
    Posts
    33
    you havent closed it

    PHP Code:
     <p> <strong><font color ='grey'>First</strong> => {$first}</p
    PHP Code:
     <p> <strong><font color='grey'>First</font></strong> => {$first}</p

  13. #13
    Join Date
    Aug 2013
    Posts
    40
    Thanks, Its worked for me ....

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles