By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
437,967 Members | 1,687 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 437,967 IT Pros & Developers. It's quick & easy.

Sending email in php

P: 32
hai all, i have this error :

Warning: mail() [function.mail]: Failed to connect to mailserver at "localhost" port 25, verify your "SMTP" and "smtp_port" setting in php.ini or use ini_set() in C:\Program Files\xampp\htdocs\tabaru\lupapass.php on line 46

this is the coding :

Expand|Select|Wrap|Line Numbers
  1. $to = $v2;
  2. $from_header = "From:";
  3. $subject = "Password anda";
  4. $body = "Hai ".$v1." ini password anda : ".$v3." apabila anda ingin mengubah password anda, anda dapat pergi ke myaccount.";
  5. (line 46) if (mail($to, $subject, $body, $from_header)) {
  6. $err="Message successfully sent!, check email anda untuk mengetahui password anda";$sudah=1;
  7. } else {
  8. $err="Message delivery failed...";
  9. }
what do i have to do? it seems that i have to set the smtp? i'm conffused, can anyone help me? thanks so much in advance
Oct 11 '08 #1
Share this Question
Share on Google+
4 Replies

Expert 5K+
P: 5,058

To use the mail function, you need to set the SMTP and smtp_port values in your PHP.ini config file to valid values.

If you are using a local mail server, then the default values should work (unless you set it up to work on a different port), but if you plan on using a remote server, then you will have to find the details for that server and use them.

Usually you only need to set the location of the SMTP server (via the SMTP value). They rarely ever mess with the port.
Oct 11 '08 #2

P: 1
Try PHPMailer:
Oct 12 '08 #3

P: 32
but how do i set the values for the SMTP port? what do set it to? thanks in advance
Oct 12 '08 #4

Expert 5K+
P: 5,058
but how do i set the values for the SMTP port? what do set it to? thanks in advance
That I can not tell you, because it will depend on the SMTP server you plan on using.

To send an email, you will need a email server, which is usually a SMTP server.
To send an email from PHP, you will need to configure PHP to use this server.

So, to begin with, you will need to either find an existing server online, like say; the email server you use with your email account.
Or, you will have to set one up yourself.

Its often easiest to use the server you use for your own email application, like Thunderbird or Outlook. You should be able to find all needed settings for that in the configuration for your email account.

I would also recommend PHPMailer or Swift Mailer rather than PHP's native mail function. They are usually much much easier to set up and work with.
Oct 12 '08 #5

Post your reply

Sign in to post your reply or Sign up for a free account.