简体   繁体   中英

Unable to send email from wamp server though i have configure smtp client

I use adsl net and iam from Nepal.

; For Win32 only.
; http://php.net/smtp
SMTP = smtp.ntc.net.np
; http://php.net/smtp-port
smtp_port = 25

Why email is not working?

Your SMTP configuration is ok! Seems like you have miss headers. Don't worry here is full description and examples

For ADSL Internet

SMTP = smtp.ntc.net.np

For WorldLink Internet

SMTP = smtp.wlink.com.np

For Example (FOR WORLDLINK)

1) Open the "php.ini".

2) Search for the attribute called "SMTP" in the php.ini file.

    SMTP = smtp.wlink.com.np
    smtp_port = 25

3) Restart the apache server so that PHP modules and attributes will be reloaded.

4) Now try to send the mail using the mail() function ,

    mail("you@yourdomain.com","test subject","test body");

you might get the warning like this, for not including headers

5) Now specify the following headers and try to send the mail again,

    $headers = 'MIME-Version: 1.0' . "\r\n";
    $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
    $headers .= 'From: sender@sender.com' . "\r\n";
    mail("you@yourdomain.com","test subject","test body",$headers);

Remember to includes headers otherwise you will get error message :)

1) Open the “php.ini“. You should know where it is located because it depends upon the particular server you're running.

2) Search for the attribute called “SMTP” in the php.ini file.

Generally you can find the line “SMTP=localhost“. change the localhost to the smtp server name of your ISP. And, there is another attribute called “smtp_port” which should be set to 25.I've set the following values in my php.ini file.

SMTP = smtp.wlink.com.np
smtp_port = 25

3) Restart the apache server so that PHP modules and attributes will be reloaded.

4) Now try to send the mail using the mail() function ,

mail(“you@yourdomain.com”,”test subject”,”test body”);

you might get the warning like this,

*Warning: mail() [function.mail]: “sendmail_from” not set in php.ini or custom “From:” header missing in C:\\Program Files\\xampp\\htdocs\\testmail.php on line 1*

5) Now specify the following headers and try to send the mail again,

$headers = ‘MIME-Version: 1.0′ . “\r\n”;
$headers .= ‘Content-type: text/html; charset=iso-8859-1′ . “\r\n”;
$headers .= ‘From: sender@sender.com’ . “\r\n”;
mail(“you@yourdomain.com”,”test subject”,”test body”,$headers);

Well that's all, the mail is sent to “you@yourdomain.com” from the localhost.

Note : Some smtp server verifies the email address of the sender so the email address which is in the place of “sender@sender.com” should be a valid and existing email address otherwise mail might not be sent to the “you@yourdomain.com”.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM