I'm finding to proper information about how to send email from localhost WAMP. And how to get authorize to send email from particular authorize email address to send any other email address.
How to configure this whole step explain me details, I already visit here some Stack Overflow answer as well as blog post but all are very confusing and old dated so it's may be possible to not working. So i need Stack Overflow users help. Thank you.
Configuring a working email client from localhost
is quite a chore, I have spent hours of frustration attempting it. At last I have found this way to send mails (using WAMP, XAMPP, etc.):
Configure this hMailServer setting:
Configure your Gmail account, perform following modification:
If you want to send email from another computer you need to allow deliveries from External to External accounts by following steps:
Try using fake sendmail to send emails in a WAMP enviroment.
Here are the steps for send email from localhost by wamp server with Sendmail.
C:\wamp\sendmail\sendmail.ini
smtp_server=smtp.gmail.com smtp_port=465 [email protected] auth_password=your_password
"C:\wamp\bin\php\php5.5.12\php.ini"
and
"C:\wamp\bin\apache\apache2.4.9\bin\php.ini"
set sendmail_path ** sendmail_path = "C:\wamp\sendmail\sendmail.exe -t"
It will surely be worked.
If you have a wamp setup that won't send emails, there is only a couple of things to do. 1. find out what the smtp server name is for your isp. The gmail thing is most likely unnecessary complication 2. create a phpsetup.php file in your 'www' folder and edit like this:
<?php
phpinfo();
?>
this will give you a handle on what wamp is using. 3. search for the php.ini file. there may be serveral. The one you want is the one that effects the output of the file above. 4. find the smtp address in the most likely php.ini. 5. Type in your browser localhost/phpsetup.php and scroll down to smtp setting. it should say 'localhost' 6. edit the php.ini file smtp setting to the name of your ISPs smtp server. check if it changes for you phpsetup.php. if it works your done, if not you are working the wrong file.
this issue should be on the Wordpress site but they are way too up-them-selves or trying to get clients.;)
Without any SMTP server sending mail,use this code for sending mail....
click below for mail sending code
listen guys first you can do this less secure your gmail account after send mail with your gmail account
You can use this php.ini setting
;smtp = smtp.gmail.com
;smtp-port = 25
;sendmail_from = my gmail is here
And sendmail.ini settings
smtp_server = smtp.gmail.com
smtp_port = 465
smtp_ssl = auto
auth_username = my gmail is here
auth_password = password
hostname = localhost
you can try this changes and i hope this code sent mail....
For me Fake Sendmail works.
What to do:
1) Edit C:\wamp\sendmail\sendmail.ini:
smtp_server=smtp.gmail.com
smtp_port=465
[email protected]
auth_password=your_password
2) Edit php.ini
and set sendmail_path
sendmail_path = "C:\wamp\sendmail\sendmail.exe -t"
That's it. Now you can test a mail.
Here is the BESTEST way to send emails using PHPmailer library, this is the only method that works for me.
require_once 'mailer/class.phpmailer.php';
$mail = new PHPMailer(); // create a new object
$mail->IsSMTP(); // enable SMTP
$mail->SMTPDebug = 1; // debugging: 1 = errors and messages, 2 = messages only
$mail->SMTPAuth = true; // authentication enabled
$mail->SMTPSecure = 'ssl'; // secure transfer enabled REQUIRED for GMail
$mail->Host = "smtp.gmail.com";
$mail->Port = 465; // or 587
$mail->IsHTML(true);
$mail->Username = "[email protected]";
$mail->Password = "xxxxxxx";
$mail->SetFrom("[email protected]");
$mail->AddAddress($to);
$logfile = dirname(dirname(__FILE__)) . '/mail.log';
try {
$mail->Body = $message;
$mail->Subject = $subject;
file_put_contents($logfile, "Content: \n", FILE_APPEND);
file_put_contents($logfile, $message . "\n\n", FILE_APPEND);
if(!$mail->Send()) {
echo "Mailer Error: " . $mail->ErrorInfo;
} else {
echo "Email has been sent";
}
} catch (Exception $e) {
#print_r($e->getMessage());
file_put_contents($logfile, "Error: \n", FILE_APPEND);
file_put_contents($logfile, $e->getMessage() . "\n", FILE_APPEND);
file_put_contents($logfile, $e->getTraceAsString() . "\n\n", FILE_APPEND);
}
a) Open the "php.ini". For XAMPP,it is located in C:\XAMPP\php\php.ini. Find out if you are using WAMP or LAMP server. Note : Make a backup of php.ini file
b) Search [mail function] in the php.ini file.
You can find like below.
[mail function]
; For Win32 only.
; http://php.net/smtp
SMTP = localhost
; http://php.net/smtp-port
smtp_port = 25
; For Win32 only.
; http://php.net/sendmail-from
;sendmail_from = postmaster@localhost
Change the localhost to the smtp server name of your ISP. No need to change the smtp_port. Leave it as 25. Change sendmail_from from postmaster@localhost to your domain email address which will be used as from address..
So for me, it will become like this.
[mail function]
; For Win32 only.
SMTP = smtp.planetghost.com
smtp_port = 25
; For Win32 only.
sendmail_from = [email protected]
auth_username = [email protected]
auth_password = example_password
c) Restart the XAMPP or WAMP(apache server) so that changes will start working.
d) Now try to send the mail using the mail() function ,
mail("[email protected]","Success","Great, Localhost Mail works");
================================================================================
Another way
Gmail servers use SMTP Authentication under SSL. I think that there is no way to use the mail() function under that circumstances, so you might want to check these alternatives:
They both support SMTP auth under SSL.
Credit : Check reference answer here
Source: Stackoverflow.com