I am updating some contact forms on several websites i made, and i am using phpmailer for it.
I'm using the SMTP method where you fill in the username and password of the email client where it needs to send to, like below:
$mail->SMTPDebug = 2; // Enable verbose debug output
$mail->isSMTP(); // Set mailer to use SMTP
$mail->Host = 'mailout.one.com'; // Specify main and backup SMTP servers
$mail->SMTPAuth = true; // Enable SMTP authentication
$mail->Username = 'info#company.com'; // SMTP username
$mail->Password = 'mypass'; // SMTP password
$mail->SMTPSecure = 'tls'; // Enable TLS encryption, `ssl` also accepted
$mail->Port = 587; // TCP port to connect to
//Recipients
$mail->setFrom('info#company.com', $email);
$mail->addAddress('info#company.com');
$mail->addReplyTo(''.$email.'');
My problem is i have to get my client his/hers emailaddress with their password, how could i solve this without asking my clients for their email information.
Related
So i currently doing a system to trigger email once the registration is submitted and pending for approval. I used github stmp email for send emails.
During testing, i am using outlook as my smtp host.
My current code
$mail->isSMTP(); //Send using SMTP
$mail->Host = 'smtp-mail.outlook.com'; //Set the SMTP server to send through
$mail->SMTPAuth = true; //Enable SMTP authentication
$mail->Username = 'abc#outlook.com'; //SMTP username
$mail->Password = '****'; //SMTP password
$mail->SMTPSecure = PHPMailer::ENCRYPTION_STARTTLS; //Enable TLS encryption; `PHPMailer::ENCRYPTION_SMTPS` encouraged
$mail->Port = 587; //TCP port to connect to, use 465 for `PHPMailer::ENCRYPTION_SMTPS` above
//Recipients
$mail->setFrom('abc#outlook.com', 'name');
$mail->addAddress('recipient#gmail.com');
However, now i would like to use my company's email instead of an outlook email as the sender email. My company email is as follow abc#kfc.com (example) , what SMTP host should i use to enable this feature ?
I currently have a website which uses PHPmailer to send emails. I am hosting it with 1&1.fr, but cannot find the information in order to actually send emails. Here is the following information that I need:
$mail->SMTPDebug = 2; // Enable verbose debug output
$mail->isSMTP(); // Set mailer to use SMTP
$mail->Host = 'smtp1.example.com;smtp2.example.com'; // Specify main and backup SMTP servers
$mail->SMTPAuth = true; // Enable SMTP authentication
$mail->Username = 'user#example.com'; // SMTP username
$mail->Password = 'secret'; // SMTP password
$mail->SMTPSecure = 'tls'; // Enable TLS encryption, `ssl` also accepted
$mail->Port = 587; // TCP port to connect to
On the 1&1.fr website, they give out the following information:
In the image, they specify multiple ports as well as an entrance/exit server; which ones am I supposed to pick and enter into my PHP file.
The rest of my code works fine (it works when I use my gmail account using 000webhost).
Any help would be greatly appreciated.
// define the $mail // just in case you miss it as it is missing in your code.
$mail = new PHPMailer();
// 0 = off (for production use)
// 1 = client messages
// 2 = client and server messages
$mail->SMTPDebug = 2; // this is to enable debug if there are errors
$mail->isSMTP(); //Tell PHPMailer to use SMTP
//Set the hostname of the mail server
$mail->Host = 'auth.smtp.1and1.fr';
// Enable authentication so you must provide username and password for SMTP authentication
$mail->SMTPAuth = true;
$mail->Username = 'user#example.com'; // SMTP username
$mail->Password = 'secret'; // SMTP password
$mail->SMTPSecure = 'tls'; // Here you are telling to use a secure connection with TLS/SSL
//Set the SMTP port number
$mail->Port = 587; // if specified tls. try also 465 as defined in the picture you post
// TCP port for secure connections. 465 is the secure port for outgoing
// emails and 993 is for incoming email using IMAP. If you use POP3 the
//incoming emails are received on 995 port number.
Hope now is more clear.
When I click on submit button
if (isset($_POST['btn_signup'])) {...
It should send an email to the registered user
require './PHPMailer/PHPMailerAutoload.php';
$mail = new PHPMailer;
$mail->isSMTP(); // Set mailer to use SMTP
$mail->Host = 'smtp.gmail.com'; // Specify main and backup SMTP servers
$mail->SMTPAuth = true; // Enable SMTP authentication
$mail->Username = 'myEmail#gmail.com'; // SMTP username
$mail->Password = 'myPassword'; // SMTP password
$mail->SMTPSecure = 'tls'; // Enable TLS encryption, `ssl` also accepted
$mail->Port = 587; // TCP port to connect to
$mail->setFrom('myEmail#gmail.com', 'Admin');
$mail->addAddress($_POST['email']); // Add a recipient
//$mail->addReplyTo('info#phpmailer.com', 'phpmailer');
//$mail->addCC('cc#example.com');
//$mail->addBCC('bcc#example.com');
$mail->isHTML(true); // Set email format to HTML
$bodyContent = '<h1>How to Send Email using PHP in Localhost</h1>';
$bodyContent .= '<p>This is the HTML email sent from localhost using PHP</p>';
$mail->Subject = 'Email from Localhost';
$mail->Body = $bodyContent;
But it doesn't work. I found people on the internet changing some php.ini and sendmail.ini codes. Am I supposed to do that?
No. You are using PHPMailer's SMTP client class, which is generally not affected by ini file settings.
It's not clear if this is all your code, but you don't have a call to the send method in what you have posted. That would certainly stop it from sending.
If it's not those things, I recommend following the troubleshooting guide and searching on here - just about everything to do with PHPMailer has been asked here before!
I've searched all around for some information on sending email with PHP, and it seems that PHPMailer is the way to go.
I don't understand much about SMTP and how mail is generated, so I'm not sure what to do in order to get started here.
My company uses Microsoft Exchange on the backend, and Microsoft Outlook 2007 on the frontend. I am trying to write some PHP code that will utilize this to send an email, but I (surprisingly) can't find anything online about how to do this.
Can anyone point me in the right direction?
More specifically, the PHPMailer example lists these items:
$mail->isSMTP(); // Set mailer to use SMTP
$mail->Host = 'smtp1.example.com;smtp2.example.com'; // Specify main and backup SMTP servers
$mail->SMTPAuth = true; // Enable SMTP authentication
$mail->Username = 'user#example.com'; // SMTP username
$mail->Password = 'secret'; // SMTP password
$mail->SMTPSecure = 'tls'; // Enable TLS encryption, `ssl` also accepted
$mail->Port = 587; // TCP port to connect to
But I have no idea where to find this information apart from username and password.
This is my configuration
$mail->isSMTP();
$mail->SMTPAuth = true;
$mail->SMTPSecure = "tls";
$mail->Host = "gator4102.hostgator.com";
$mail->Port = 465;
$mail->Username = 'test#some.com';
$mail->Password ='jyghvbjyhj';
It throws following error
SMTP -> ERROR: HELO not accepted from server:
SMTP -> NOTICE: EOF caught while checking if connectedLanguage string failed to load: tls
Mail gets delivered though sometimes. Please help.
Change:
$mail->Port = 465;
To:
$mail->Port = 587;
For tls, 587 port is used.
If you are using
$mail->SMTPSecure = "tls";
Then your setting should be as following :
$mail->IsSMTP();
$mail->SMTPAuth = true;
$mail->SMTPSecure = "tls";
$mail->Host = "gator4102.hostgator.com";
$mail->Port = 587;
$mail->Username = "yourusername#abc.com";
$mail->Password = "yourpassword";
If you get response from server, it's already good enough. This means that you connect to server successfully.
You are probably trying to connect to the port on which another server application is listening. First, check again that you connect to port on which SMTP server is listening and waiting for TLS connection. Try to connect to another server to locate problem. Also, you can try another PHP library.