Go Back   TechArena Community > Software > Software Development
Become a Member!
Forgot your username/password?
Tags Active Topics RSS Search Mark Forums Read

Reply
 
Thread Tools Search this Thread
  #1  
Old 10-06-2011
Member
 
Join Date: May 2011
Posts: 468
Sending email by using PHP and SMTP?

Hey can anyone help me by giving some code on how to send email by using PHP and SMTP? I have my own code but it has not been working properly please suggest some general views of code so that I can make out the coding according to my case or anyone who have been doing this can show me there coding to help me how you all have done it? Please help me guys as soon as possible any clue would be appreciated.
Reply With Quote
  #2  
Old 10-06-2011
Member
 
Join Date: Apr 2009
Posts: 567
Re: Sending email by using PHP and SMTP?

Hello if you would have provided us with your code then it would have been more better so that would have tried to make out what has went wrong or tell us what error you are been displayed anyways jus check if your code has fshockopen is enabled if you are using it otherwise I have a solution just go through it and look out if it helps you
Code:
<?php

       require_once "Mail.php";

        $from = "<me.gmail.com>";
        $to = "<sending to.yahoo.com>";
        $subject = "Hello!";
        $body = "Hi,\n\n What?s up with you?";

        $host = "ssl://smtp.gmail.com";
        $port = "465";
        $username = "<mine.gmail.com>";
        $password = "Password";

        $headers = array ('From' => $from,
          'To' => $to,
          'Subject' => $subject);
        $smtp = Mail::factory('smtp',
          array ('host' => $host,
            'port' => $port,
            'auth' => true,
            'username' => $Username,
            'password' => $Password));

        $mail = $smtp->send($to, $headers, $body);

        if (PEAR::is Error($mail)) {
          echo("<p>" . $mail->get Message (). "</p>");
         } else {
          echo("<p>Message has been delivered!</p>");
         }

    ?>
Just check this out if you get any clue enjoy coding.
Reply With Quote
  #3  
Old 10-06-2011
Member
 
Join Date: Mar 2010
Posts: 144
Re: Sending email by using PHP and SMTP?

Hey, I think this would be working with several changes according to our requirement and as some changes in that SMTP server detail as it is been mentioned by you, you need to take care of that to I personally think you need to change that SMTP details to I have a little code to work with this SMTPconfig.PHP here is it
Code:
<? Php
$SmtpServer=?127.0.0.1?;
$SmtpPort=?25?;
$SmtpUser=?Username?
$SmtpPass=?Password?;
?>
change it and see if you are solved with your dought.
Reply With Quote
  #4  
Old 10-06-2011
Member
 
Join Date: May 2009
Posts: 620
Re: Sending email by using PHP and SMTP?

Oh yes this is a good solution but I have my own solution which I have been using and it?s not having much difference but just a syntax difference I would like to share it with you so that if this solutions haven?t solved your problem might this one would be as same as yours and you can get through it
Code:
<?php
require_once "Mail.php";
$from = "senders name  <name@myemail.com>";
$to = "sending to whom <name@targetemail.com>";
$subject = "what?s going on !";
$body = "Hello,\n\n  how are you doing?";
$host = "mail.mailserver.com";
$username = "Username@myemail.com";
$password = "Password";
$headers = array ('From' => $from,
'To' => $to,
'Subject' => $subject);
$smtp = Mail::factory('smtp',
array ('host? => $host,
'auth' => true,
'username' => $Username,
'password' => $Password));
$mail = $smtp->send($to, $headers, $body);
if (PEAR::isError($mail)) {
echo("<p>" . $mail->getMessage() . "</p>");
} else {
echo ("<p>Message successfully sent!</p>");
}
?>
hope it finds you the way to get rid of your problem.
Reply With Quote
  #5  
Old 10-06-2011
Member
 
Join Date: May 2009
Posts: 503
Re: Sending email by using PHP and SMTP?

Well I used this and it has worked to me friend I think this solutions are enough and I think working or going through different solutions and syntax would confuse you stick to the basic and go on try taking helps from the professors you got around because they would be able to go through your coding and they would help you in much better and no need to have n number of attempts because I feel personally that is a waste of time just going through different number of attempts all the time this codes are perfect according to me it did worked to me so just make several changes and get it done.
Reply With Quote
Reply

  TechArena Community > Software > Software Development
Tags: , , , ,



Thread Tools Search this Thread
Search this Thread:

Advanced Search


Similar Threads for: "Sending email by using PHP and SMTP?"
Thread Thread Starter Forum Replies Last Post
Set up for sending SMTP mail Through Exchange online System. Kevlina Technology & Internet 5 09-07-2011 04:35 PM
5.5.0 smtp;550-Verification failed error while sending email Kaysel Small Business Server 4 16-06-2010 04:51 PM
Sending Mail thru Gmail.com a/c using smtp client in .NET GameBond Windows Software 6 11-05-2010 10:28 PM
Email being sent again when SMTP service restarted sayeed Small Business Server 1 14-04-2008 08:36 AM
Free pop3 ,smtp or imap email providers abdulzis Technology & Internet 10 21-12-2006 04:40 AM


All times are GMT +5.5. The time now is 05:10 AM.