Results 1 to 5 of 5

Thread: Sending email by using PHP and SMTP?

  1. #1
    Join Date
    May 2011
    Posts
    470

    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.

  2. #2
    Join Date
    Apr 2009
    Posts
    569

    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.

  3. #3
    Join Date
    Mar 2010
    Posts
    145

    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.

  4. #4
    Join Date
    May 2009
    Posts
    637

    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.

  5. #5
    Join Date
    May 2009
    Posts
    511

    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.

Similar Threads

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

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,714,268,181.30439 seconds with 17 queries