I am trying to send the messages through "email to sms" gateway for that i have the following code:
<?php
require 'mailer/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 = '<my-email>#gmail.com'; // SMTP username
$mail->Password = '<password>'; // SMTP password
$mail->SMTPSecure = 'tls'; // Enable TLS encryption, `ssl` also accepted
$mail->Port = 587; // TCP port to connect to
$mail->setFrom('<my-email>#gmail.com', 'abhishek');
$mail->addAddress('<mob-no>#bplmobile.com'); // Add a recipient
$mail->isHTML(true); // Set email format to HTML
$bodyContent = 'Hello world';
$mail->Subject = 'Demo Subject';
$mail->Body = $bodyContent;
if(!$mail->send()) {
echo 'Message could not be sent.';
echo 'Mailer Error: ' . $mail->ErrorInfo;
} else {
echo 'Message has been sent';
}
?>
I have got the gateway from here. I have tried all the gateways in the link, but the message doesn't seems to be deliver.
Email to SMS gateways are a thing of past. Today none of the providers provide email address based on number. Best solution is to use a sms gateway like twilio.
Related
I'm using PHPMailer and have tried others but this simply does not work. I keep getting an error that the server keeps denying me access. Here is the example code used:
<?php
require 'PHPMailerAutoload.php';
$mail = new PHPMailer;
//$mail->SMTPDebug = 3; // Enable verbose debug output
$mail->isSMTP(); // Set mailer to use SMTP
$mail->Host = 'smtp.office365.com'; // Specify main and backup SMTP servers
$mail->SMTPAuth = true; // Enable SMTP authentication
$mail->Username = 'xx#xx.com'; // SMTP username
$mail->Password = 'xxx'; // SMTP password
$mail->SMTPSecure = 'tls'; // Enable TLS encryption, `ssl` also accepted
$mail->Port = 587; // TCP port to connect to
$mail->setFrom('from#example.com', 'Mailer');
$mail->addAddress('joe#example.net', 'Joe User'); // Add a recipient
$mail->addReplyTo('info#example.com', 'Information');
$mail->isHTML(true); // Set email format to HTML
$mail->Subject = 'Here is the subject';
$mail->Body = 'This is the HTML message body <b>in bold!</b>';
$mail->AltBody = 'This is the body in plain text for non-HTML mail clients';
if(!$mail->send()) {
echo 'Message could not be sent.';
echo 'Mailer Error: ' . $mail->ErrorInfo;
} else {
echo 'Message has been sent';
}
I'm using the same settings as shown in their official documentation: https://support.office.com/en-gb/article/POP-and-IMAP-settings-for-Outlook-Office-365-for-business-7fc677eb-2491-4cbc-8153-8e7113525f6c
What seems to be an issue? I have checked online in a number of posts but nothing seems to be working. Any ideas?
For GoDaddy Office365 accounts you must use the GoDaddy secure SMTP server: smtpout.secureserver.net
Please refer to https://za.godaddy.com/help/server-and-port-settings-for-workspace-email-6949.
my php mailer is working fine on localhost but when I m running same code on cpanel I m getting Error message :SMTP connect() failed
<?php
require 'PHPMailer/PHPMailerAutoload.php';
$mail = new PHPMailer;
$mail->isSMTP();
$mail->Host = "tls://smtp.gmail.com";
$mail->SMTPAuth = true;
$mail->Username = '********#gmail.com';
$mail->Password = '********';
$mail->Port = 587;
$mail->setFrom('sender#gmail.com', 'Mailer');
$mail->AddAddress('receiver#gmail.com', 'Joe User');
$mail->addReplyTo('sender#gmail.com', 'Information');
$mail->isHTML(true);
$mail->Subject = 'Here is the subject';
$mail->Body = 'This is the HTML message body <b>in bold!</b>';
$mail->AltBody = 'This is the body in plain text for non-HTML mail clients';
if(!$mail->send()) {
echo 'Message could not be sent.';
echo 'Mailer Error: ' . $mail->ErrorInfo;
} else {
echo 'Message has been sent';
}
?>
Pls help me, where I am getting wrong?
CPanel blocks access to external SMTP servers by default.
Disable this restriction in whm > security center > SMTP Restrictions disable
This works
<?php
require_once('./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.mail.yahoo.com";
$mail->Port = 465; // or 587
$mail->IsHTML(true);
$mail->Username = "xxxxxx#ymail.com";
$mail->Password = "xxxxxx";
$mail->SetFrom("xxxxx#ymail.com");
$mail->Subject = "Test";
$mail->Body = "hello";
$mail->AddAddress("xxxxx#ymail.com");
if(!$mail->Send()) {
echo "Mailer Error: " . $mail->ErrorInfo;
} else {
echo "Message has been sent";
}?>
You might have forgotten to enable SMTP access (it's part of IMAP access in settings) to your GMail account.
Also, "tls://smtp.gmail.com" is not a valid SMTP server address. Use $mail->SMTPSecure = "tls"; if you want to use TLS.
Thanks for your suggestions, It's really appreciated :-)
I got the solution is as follows.
1>give Absolute path for PHPMailerAutoload.php
2>host name as "localhost"
3>create dummy emailId on server
<?php
require'/home/username/public_html/phpmailertesting/PHPMailer/PHPMailerAutoload.php';
$mail = new PHPMailer;
$mail->SMTPDebug =3; // Enable verbose debug output
$mail->isSMTP(); // Set mailer to use SMTP
$mail->Host = 'localhost'; // Specify main and backup SMTP servers
$mail->SMTPAuth = true; // Enable SMTP authentication
$mail->Username = 'info#hostname.com'; // SMTP username
$mail->Password = '*****'; // SMTP password
$mail->SMTPSecure = 'tls'; // Enable TLS encryption, `ssl` also accepted
$mail->Port = 587; // TCP port to connect to
$mail->setFrom('info#hostname.com', 'Mailer');
$mail->addAddress('*******#gmail.com'); // Name is optional
//$mail->addReplyTo('info#hostname.com', 'Information');
//$mail->addCC('*******#gmail.com');
//$mail->addBCC('bcc#example.com');
//$mail->addAttachment('/var/tmp/file.tar.gz'); // Add attachments
//$mail->addAttachment('/tmp/image.jpg', 'new.jpg'); // Optional name
$mail->isHTML(true); // Set email format to HTML
$mail->Subject = 'Here is the subject';
$mail->Body = 'This is the HTML message body <b>in bold!</b>';
$mail->AltBody = 'This is the body in plain text for non-HTML mail clients';
if(!$mail->send()) {
echo 'Message could not be sent.';
echo 'Mailer Error: ' . $mail->ErrorInfo;
exit();
} else {
echo 'Message has been sent';
}
?>
You need to buy Cpanel/WHM from the ISP company to enable access to external SMTP emails like Gmail. first, disable: WHM > security center > SMTP Restrictions is Disable.
and make sure CSF Firewall is "SMTP_BLOCK" setting is enabled.
if you using Gmail in your security setting enable less security which you can smtp auth.
PHPMailer recommended using SSL for all firewalls and security issues.
I'm trying to learn PHPMailer and I don't understand why it needs an email address and password.
$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
It's not coming from a persons email, it's coming from the site. What email am I supposed to put here and why?
The email address is the address which the emails are sent from. The username and password are required for SMTP servers that require authentication in order to send mail.
The way email works is that party 1 has an email account which it uses to send mail to party 2. Party 1 can be a site, a person, a script or something else, but it still needs to have an email account to be able to send email.
This is the way SMTP (Simple Mail Transfer Protocol) has been defined, and you need to follow the definitions of that protocol to get your mail delivered.
It is not necessary to provide password -
<?php
require("class.phpmailer.php");
$mail = new PHPMailer();
$mail->IsSMTP(); // telling the class to use SMTP
$mail->Host = "smtp.example.com"; // SMTP server
$mail->From = "example#gmail.com";
$mail->AddAddress("example#gmail.com");
$mail->Subject = "First PHPMailer Message";
$mail->Body = "Hi! \n\n This is my first e-mail sent through PHPMailer.";
$mail->WordWrap = 50;
if(!$mail->Send()) {
echo 'Message was not sent.';
echo 'Mailer error: ' . $mail->ErrorInfo;
} else {
echo 'Message has been sent.';
}
?>
Click here
Here is my code:
require 'phpmailertesting/PHPMailerAutoload.php';
$mail = new PHPMailer;
//$mail->SMTPDebug = 3; // Enable verbose debug output
$mail->isSMTP(); // Set mailer to use SMTP
$mail->Host = 'send.one.com'; // Specify main and backup SMTP servers
$mail->SMTPAuth = true; // Enable SMTP authentication
$mail->Username = 'myemailhidden'; // SMTP username
$mail->Password = 'mypasswordhidden'; // SMTP password
$mail->SMTPSecure = 'ssl'; // Enable TLS encryption, `ssl` also accepted
$mail->Port = 465; // TCP port to connect to
$mail->From = 'myemailhidden';
$mail->FromName = 'My Name';
$mail->addAddress('example#example.com'); // Name is optional
$mail->addCC('cc#example.com');
$mail->addBCC('bcc#example.com');
//$mail->addAttachment('/var/tmp/file.tar.gz'); // Add attachments
//$mail->addAttachment('/tmp/image.jpg', 'new.jpg'); // Optional name
$mail->isHTML(true); // Set email format to HTML
$mail->Subject = 'Here is the subject';
$mail->Body = 'This is the HTML message body <b>in bold!</b>';
$mail->AltBody = 'This is the body in plain text for non-HTML mail clients';
if(!$mail->send()) {
echo 'Message could not be sent.';
echo 'Mailer Error: ' . $mail->ErrorInfo;
} else {
echo 'Message has been sent';
}
I have tried changing the port and the type of secure connection to "TSL" and "SSL" and nothing. Ive looked at the answers already and none of them solve it. Any answers? Thanks
I enabled the SMTP debugger and this is what it said "Connection: opening to ssl://send.one.com:465, t=300, opt=array ( ) 2014-12-15 15:46:40 SMTP ERROR: Failed to connect to server: Connection timed out (110) 2014-12-15 15:46:40 SMTP connect() failed"
Your hosting company, one.com, blocks outgoing mail ports intentionally to restrict malicious PHP scripts. The send.one.com address is meant for external mail clients such as your mobile phone, email client, etc. and not for internal mailing scripts from your website.
As per their support document concerning sending emails from your website, you must change the host to their internal SMTP address, mailout.one.com - since this is an internal relay, you must also use port 25 and disable any security such as TLS or SSL. You must also disable authentication.
Here is the correct configuration:
$mail->isSMTP(); // Set mailer to use SMTP
$mail->Host = 'mailout.one.com'; // Specify main and backup SMTP servers
$mail->SMTPAuth = false; // Authentication must be disabled
$mail->Username = 'myemailhidden';
$mail->Password = ''; // Leave this blank
$mail->Port = 25; // TCP port to connect to
The other solutions did not work for me; this one did:
$mail->isSMTP();
$mail->Host = 'mailout.one.com';
$mail->SMTPAuth = false; // disable SMTP authentication
$mail->Username = '[your one.com-email]';
$mail->Password = '[your one.com-email password]';
$mail->SMTPSecure = ''; // leave this blank!
$mail->Port = 25;
Let me know if it helped you, too!
New to SO, so cant vote gold on you #sjagr
Had this problem, and as I use one.com, there were no biggey with the solution from #sjagr :)
You can try this full output in you file, and make sure to link the required docs.
<?php
require 'PHPMailerAutoload.php';
$mail = new PHPMailer;
//$mail->SMTPDebug = 3;
$mail->isSMTP();
$mail->Host = "mailout.one.com";
$mail->SMTPAuth = false;
$mail->Port = 25;
$mail->From = 'your#domain.se';
$mail->FromName = 'Mailer';
$mail->addAddress('sendtothis#domain.se');
$mail->addReplyTo('ireply#domain.se', 'Information');
$mail->addBCC('bcc#example.com');
$mail->isHTML(true);
$mail->Subject = 'Here is the subject';
$mail->Body = 'hejehej';
$mail->AltBody = 'This is the body in plain text for non-HTML mail clients';
if(!$mail->send()) {
echo 'Message could not be sent.';
//echo 'Mailer Error: ' . $mail->ErrorInfo;
} else {
echo 'Message has been sent, ja e fan inte tom';
} ?>
Please can some one suggest me codes to send mails using yahoo smatp, and php..
require("class.phpmailer.php"); // be sure to change this to your location!
$mail = new PHPMailer();
$mail->IsSMTP();
$mail->SMTPAuth = true; // enable SMTP authentication
$mail->SMTPSecure = "ssl"; // sets the prefix to the servier
$mail->Host = "smtp.mail.yahoo.com"; // sets yahoo as the SMTP server
$mail->Port = 25; // set the SMTP port
$mail->Username = "sumthing#yahoo.com"; // yahoo username
$mail->Password = "password"; // yahoo password
$mail->From = "sumthing#yahoo.com";
$mail->FromName = "myname";
$mail->AddAddress("you#example.com");
$mail->Subject = "Test PHPMailer Message";
$mail->Body = "Hi! \n\n This was sent with phpMailer_example3.php.";
if(!$mail->Send()) {
echo 'Message was not sent.';
echo 'Mailer error: ' . $mail->ErrorInfo;
} else {
echo 'Message has been sent.';
}
This code is giving me errrors 'Could not connect to SMTP host".
Many of the sites providing SMTP do not support SSL (SMTP-S). If supported is usually in different port, such as 465. Connecting to 465 often fails. Try commenting out
$mail->SMTPSecure = "ssl"
Try also first without authentication to make sure the connection works.