1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Using Php to send email

Discussion in 'PHP' started by Jasonfminghei, Oct 3, 2005.

  1. #1
    hello friends
    i am young in learning php, and now i face a problem which i can't solve for a week. :( I want to send a email through using php. But the IE display this message:
    Warning: mail(): Failed to connect to mailserver at "netvigator.com" port 25, verify your "SMTP" and "smtp_port" setting in php.ini or use ini_set() in c:\appserv\www\revealtech\survey\sendemail.php on line 15

    Warning: mail(): Failed to connect to mailserver at "netvigator.com" port 25, verify your "SMTP" and "smtp_port" setting in php.ini or use ini_set() in c:\appserv\www\revealtech\survey\sendemail.php on line 15

    here is the code in php.ini:
    [mail function]
    ; For Win32 only.
    SMTP = netvigator.com

    ; For Win32 only.
    sendmail_from = honmen@netvigator.com

    here is the code in my php file:
    $to = "pw_group14@yahoo.com.hk";
    $header = "From: honmen@netvigator.com";
    $subject = "testing mail";
    $message = "no reply pls";
    mail($to, $subject, $message, $header);
    ini_set("SMTP","netvigator.com");
    ini_set("SMTP_PORT", 25);
    ini_set("sendmail_from","honmen@netvigator.com");
    help me please, thanks for all help ;)

    thanks for all help
     
    Jasonfminghei, Oct 3, 2005 IP
  2. KingSEO

    KingSEO Peon

    Messages:
    295
    Likes Received:
    28
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Is there a SMTP running on port 25 available on that host from your IP? Send the emails thru localhost instead? Install sendmail or something...
     
    KingSEO, Oct 3, 2005 IP
  3. ChrisB

    ChrisB Well-Known Member

    Messages:
    580
    Likes Received:
    13
    Best Answers:
    0
    Trophy Points:
    128
    #3
    ok. Why are you using sendmail anyway!? just simply use the php mail() function. Try this:

    <?
    $ToEmail = "pw_group14@yahoo.com.hk";
    
    $ToSubject = "testing mail";
    
    $EmailBody = "hi! It worked!!";
    
    mail($ToName." <".$ToEmail.">",$ToSubject, $EmailBody, "From: ".$FirstName." <".$Email.">");
    
    ?>
    PHP:
    Paste this script into a file named 'mail.php' for example and surf to it using your browser. You should receive an email if your mail() function is working on your server.

    Offcourse, altermatly you will need to collect the variables from a submitted form .... but you have this form already probably...just make sure the variables match.

    Hope this helps.
     
    ChrisB, Oct 3, 2005 IP
  4. Amos

    Amos Peon

    Messages:
    224
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Keep in mind that if you don't include headers when using the mail function, your email can more easily be marked as spam.
     
    Amos, Oct 5, 2005 IP
  5. Jasonfminghei

    Jasonfminghei Peon

    Messages:
    2
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Thank you for all help. I am tried, but the problem is the ISP mail address not accept smtp_port 25:confused:
     
    Jasonfminghei, Oct 6, 2005 IP
  6. ChrisB

    ChrisB Well-Known Member

    Messages:
    580
    Likes Received:
    13
    Best Answers:
    0
    Trophy Points:
    128
    #6
    ok. good luck!
     
    ChrisB, Oct 7, 2005 IP
  7. markkk

    markkk Well-Known Member

    Messages:
    1,143
    Likes Received:
    49
    Best Answers:
    0
    Trophy Points:
    140
    #7

    are you sure it is only netvigator.com? maybe youre missing SMTP.netvigator.com or mail.netvigator.com

    this would be okay if your SMTP is just open relay. but if it is Login Authenticated that is another problem. you need a script that will accept SMTP hostname/port/ username/ password.
     
    markkk, Oct 7, 2005 IP