Few questions about email sending

Discussion in 'PHP' started by tanvirtonu, Nov 9, 2007.

  1. #1
    I have tried several ways to send mail but I hav failed and I m veryyyyyy upset. Now
    I have few question about mail sending in php

    1. I cant/dont use the smtp server of my ISP. Now which server I can send my mail thru?

    2. I want to use yahoo smtp mail server. Now do I have to set yahoo smtp server name and port in php.ini? Cant I set these (both name and port)dynamically in php. if so, how?

    3.If the server name I m using uses authenticated smtp, WHERE and how to put code for user id and password in php .
    If in mail header then in which format?

    4. I hav come to know the following things from website of yahoo-

    Outgoing Mail (SMTP) Server:
    smtp.mail.yahoo.com (Use SSL, port: 465, use authentication)

    I am also giving u my account details
    My yahoo id- (created 2day for the test)
    password- abcdefg


    Now would anybody pls pls tel me or write me a simple code by which I can send mail without using my Isp's smtp server. DO I need to use those info. in php.ini . Or is there any way to add them dynamically in php.

    I once tried with the following code but nothing happened

    
    <?php
    //mail($recepeint,$subject,$msg,$mailheader);
    //define the receiver of the email
    $to = 'bhonest_4ever@yahoo.com';
    //define the subject of the email
    $subject = 'Test email';
    //define the message to be sent. Each line should be separated with \n
    $message = "Hello World!\r\nThis is my first mail.";
    //define the headers we want passed. Note that they are separated with \r\n
    $headers = "From: tanvirtonu@yahoo.com\r\nReply-To: tanvirtonu@yahoo.com";
    //send the email
    $mail_sent = @mail( $to, $subject, $message, $headers );
    //if the message is sent successfully print "Mail sent". Otherwise print "Mail failed" 
    echo $mail_sent ? "Mail sent" : "Mail failed";
    
    echo "Thank You <b>Tanvir</b> for ur message";
    echo "<p>Your mail address is <p>$to </p>";
    echo "<p>Your message was <p> $message </p>";
    
    ?>
    //I set server=smtp.mail.yahoo.com and port=25 in php.ini and restart the server .
    
    PHP:

    NB. If I configure php.ini in php code using ini_set(), wouldn't it be permanent next time. But what happens if I host these php file in another server. There can be a lot other php files trying to do the same thing. Isn't it a problem.
    I can also send mail using a free smtp server and a mail client in my windows pc which requires default 25 port for smtp. Should I use this port-25 with the above server name smtp.mail.yahoo.com[/php]
     
    tanvirtonu, Nov 9, 2007 IP
  2. Colbyt

    Colbyt Notable Member

    Messages:
    3,224
    Likes Received:
    185
    Best Answers:
    0
    Trophy Points:
    210
    #2
    I have never had a problem using the sendmail function of PHP. Maybe your problem is your choice of hosts??
     
    Colbyt, Nov 9, 2007 IP
  3. krakjoe

    krakjoe Well-Known Member

    Messages:
    1,795
    Likes Received:
    141
    Best Answers:
    0
    Trophy Points:
    135
    #3
    Most smtp servers are setup to require pop authentication before they will allow you to transmit mail, if you must use an external smtp server there are plenty of classes available for doing so ...
     
    krakjoe, Nov 9, 2007 IP
  4. armatik

    armatik Peon

    Messages:
    27
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #4
    I'm pretty sure you can't use their server without identifying yourself on an email account on their servers.
     
    armatik, Nov 9, 2007 IP
  5. seanybob

    seanybob Peon

    Messages:
    53
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    I'd have to agree with this fella

    And I believe he's right there.
     
    seanybob, Nov 9, 2007 IP