I'm using WampServer on Windows to test a site. I have a registration system where users get a confirmation email.
Is it possible to send emails from a localhost?
I'm using WampServer on Windows to test a site. I have a registration system where users get a confirmation email.
Is it possible to send emails from a localhost?
You have $headers .= '...';
followed by $headers = '...';
; the second line is overwriting the first.
Just put the $headers .= "Bcc: $emailListrn";
say after the Content-type
line and it should be fine.
On a side note, the To
is generally required; mail servers might mark your message as spam otherwise.
$headers = "From: no-reply@thepartyfinder.co.ukrn" .
"X-Mailer: phprn";
$headers .= "MIME-Version: 1.0rn";
$headers .= "Content-Type: text/html; charset=ISO-8859-1rn";
$headers .= "Bcc: $emailListrn";
Try using SMTP server with gmail.
ini_set("SMTP","ssl://smtp.gmail.com");
ini_set("smtp_port","465");
or else there are many PHP mailer library. which simplifies things for you and makes it so easier to use. my fav is swift mailer. the best part about is you don't have to mess with your core php configuration file and the documentation too is very easy to read.
for example if you want to send a mail using PHP's swift mailer library it is as simple as.
require_once 'lib/swift_required.php';
// Create the Transport
$transport = Swift_SmtpTransport::newInstance('smtp.example.org', 25)
->setUsername('your username')
->setPassword('your password');
// Create the Mailer using your created Transport
$mailer = Swift_Mailer::newInstance($transport);
// Create a message
$message = Swift_Message::newInstance('Wonderful Subject')
->setFrom(array('john@doe.com' => 'John Doe'))
->setTo(array('receiver@domain.org', 'other@domain.org' => 'A name'))
->setBody('Here is the message itself');
// Send the message
$result = $mailer->send($message);
you can refer the documentation for more information on the official website http://swiftmailer.org/docs
PHPMailer is the best to use for email.
checkout some below links which will help you in future also:
may this help you.
Try this
sendmail.ini
[sendmail]
smtp_server=smtp.gmail.com
smtp_port=465
smtp_ssl=ssl
error_logfile=error.log
debug_logfile=debug.log
auth_username=[email]@gmail.com
auth_password=[email password]
pop3_server=
pop3_username=
pop3_password=
force_sender=[email]@gmail.com
force_recipient=
hostname=smtp.gmail.com
php.ini
[mail function]
SMTP = smtp.gmail.com
smtp_port = 465
sendmail_path = ""C:xamppsendmailsendmail.exe" -t"
mail.add_x_header=Off
If you want to send emails from localhost directly, you need to install a Mail Transport Agent (MTA), or if you like, a SMTP service.
IIS provides one. You can otherwise find some others on Google.
You can also change your
php.ini
mail settings. This won't uselocalhost
per say to send emails, but a relay host that will allow you to send emails from a PHP script.