0

I have tried every single way on the internet but non of those solve my problem. I'm using WAMP 2.2

I'm using a form to require nyu student email and when the student submit the form it will send to another nyu.edu email and receive a confirmation.

original code:

// send the notification email
$mailto =  $EMAIL;//requied from the form
$subject = "Thank you for your nomination!";
$body = 
"Dear ".$NAME.",

This confirms that we have received your nomination of ".$NOMINEE." for a teaching award. Thank you for your submission.

NYU Teaching Awards Team";
$headers = "From: somemail@example.com\n\n";
if (mail($mailto, $subject, $body, $headers)) {
    echo("<p>Message successfully sent!</p>");
} else {
    echo("<p>Message delivery failed...</p>");
}
//end notification email


// send the notification email
$mail_to =  "somemail@example.com";
$email_subject = "New Teaching Award Nomination";
$email_body = 
"A new teaching award nomination has been submitted by ".$NAME." nominating ".$NOMINEE.".";
$email_headers = "From: somemail@example.com\n\n";
if (mail($mail_to, $email_subject, $email_body, $email_headers)) {
    echo("<p>Message successfully sent!</p>");
} else {
    echo("<p>Message delivery failed...</p>");
}
//end notification email

the error msg is Failed to connect to mailserver at "localhost" port 25, verify your "SMTP"

so then I tied to put

ini_set("SMTP","nyu.smtp.edu");
ini_set("smtp_port","587");

but it shows: Failed to connect to mailserver at "nyu.smtp.edu" port 587, verify your "SMTP"

I don't know what to do!! please help

brandonscript
  • 68,675
  • 32
  • 163
  • 220
Sio
  • 27
  • 1
  • 1
  • 9
  • This is probably because you are not providing any authentication credentials. – thatidiotguy Jan 07 '14 at 20:20
  • Edited out your personal information from the question; don't add it back in please. – brandonscript Jan 07 '14 at 20:20
  • Also, If you end up needing to use authentication (after you fix the SMTP port) you'll need to use something like [PEAR](http://stackoverflow.com/questions/12166468/sending-html-message-through-pear-while-using-smtp-authentication-returns-an-err) – brandonscript Jan 07 '14 at 20:25
  • If you want to have RFC conformant mails, consider using the PHP mailer class SwiftMailer: http://swiftmailer.org/. It's easy to use, object-oriented and offers all the features you'll need. – lorenz Jan 07 '14 at 20:33

2 Answers2

2

"nyu.smtp.edu" doesn't look right. Try "smtp.nyu.edu". You might go back to using port 25.

Xavier J
  • 4,326
  • 1
  • 14
  • 25
  • This works very well, there is no other installation of mail servers!! Thank yo very much – Sio Jan 10 '14 at 17:33
0

Be sure that sendmail is installed on your server. But you have to consider PEAR if you want more options in sending mails.

makriria
  • 383
  • 1
  • 9