I don't know what is wrong i am transferring my files to a laptop and i am having trouble sending mail in php mailer where check my phpinfo in the laptop it seems ok in fact same as the one in my desktop..
SMTP smtp.mail.yahoo.com smtp.mail.yahoo.com
smtp_port 25 25
the error is
Could not connect to smtp host wrong
ive opened the openssl extension
and the smtp is as u can see
in case you need here is my code
$mail = new PHPMailer();
$mail->IsSMTP(); // send via SMTP
$mail->Host="smtp.mail.yahoo.com"; // SMTP servers
$mail->SMTPAuth = true; // turn on SMTP authentication
$mail->Username = "******"; // SMTP username
$mail->Password = "******"; // SMTP password
$mail->From = "****";
$mail->FromName = "******";
$mail->AddAddress(******","*******");
$mail->WordWrap = 50; // set word wrap
$mail->IsHTML(true); // send as HTML
$mail->Subject = "Welcome to LilShop";
$mail->Body = ' Message ';
$mail->Send();
please help thanks
Add
$mail->Port=465;
$mail->SMTPSecure = "tls";
and then it should work. Yahoo SMTP requires port and tls. You can also check out the PHPMailer examples here: http://phpmailer.worxware.com/index.php?pg=exampleasmtp
Related
I try to sent mail on submitting the form using the SMTP server. I get mail on my Gmail account but didn't get mail on webmail.
Is it an SMTP server issue or webmail?
What can I do to send mail on webmail?
Have to something remaining config in webmail?
Below I tried code:
$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 = '**********'; // SMTP username
$mail->Password = '**********'; // SMTP password
$mail->SMTPSecure = 'ssl'; // Enable TLS encryption, `ssl` also accepted
$mail->Port = 465; // TCP port to connect to
$mail->setFrom('info#abc.com','ABC');
$mail->addAddress($email); // Add a recipient
$mail->isHTML(true); // Set email format to HTML
$mail->Subject = 'ABC - Register Successfully';
$mail->Body = "
<h4>Dear $name,</h4>
<p>Thank you! Your registration has been successful.</p>
<p>If you need any help or query, please feel free to drop an email using the following email address: <strong>info#abc.com</strong></p>
<p>We appreciate your patience. </p>
<h4>Thanking You,</h4>
";
$mail->send();
I've got a bizarre problem here. I'm trying to use PHPMailer to send an email, through SMTP. I have a website hosted by GoDaddy and it's that SMTP account that I'm trying to use to send the mail.
It works if I execute my PHP file on my localhost server.
It does not work if I execute my PHP file on GoDaddy's server.
The error message I get is:
SMTP -> ERROR: Failed to connect to server: Connection refused (111)
I checked phpinfo on both localhost and the remote server. Both have smtp_port listed as 25. I'm using WAMP on my machine and the server is some form of Linux (which I know nothing about and have no idea how to administer).
Here is the code in question:
INDEX.PHP:
<?php
date_default_timezone_set('America/Los_Angeles');
include_once("phpmailer/class.phpmailer.php");
$mail = new PHPMailer;
$mail->SMTPDebug = 1;
$mail->Port = 25;
$mail->IsSMTP();
$mail->Host = 'smtpout.secureserver.net';
$mail->SMTPAuth = true;
$mail->Username = 'username#site.com';
$mail->Password = 'super_secret_password';
$mail->SMTPSecure = ''; // tried ssl and tls, with same result
$mail->ClearAddresses();
$mail->AddAddress('receiver#hotmail.com', 'Receiver Name');
$mail->From = "username#site.com";
$mail->FromName = "Username";
$mail->Subject = 'Hi there';
$mail->Body = "This is a message";
if ($mail->Send()) {
echo "Message sent!\n";
}
else {
echo "Message failed!\n";
print_r($mail->ErrorInfo);
}
exit();
?>
I think you should perform two step
1) check your port as suggested on godaddy support http://support.godaddy.com/help/article/319/what-do-i-do-if-i-have-trouble-connecting-to-my-email-account
2)use "relay-hosting.secureserver.net" as your host instead of "smtpout.secureserver.net"
GoDaddy does allow to send emails using Gmail as your SMTP, just need to get rid of the smtp.gmail.com and use their Host instead. This is my setup:
$mail = new PHPMailer();
$mail->isSMTP();
$mail->Host = "relay-hosting.secureserver.net";
$mail->Username = "your-account#gmail.com";
$mail->Password = "yourpassword";
// ...
// send from, send to, body, etc...
Reference (see first two posts) http://support.godaddy.com/groups/web-hosting/forum/topic/phpmailer-with-godaddy-smtp-email-server-script-working/
If your hosting has own email server, the server will use the following ports 25,465,587.
Settings for GoDaddy:
$mail->isSMTP();
$mail->Host = localhost;
$mail->SMTPAuth = true;
$mail->Username = 'example#gmail.com';
$mail->Password = 'password';
//$mail->SMTPSecure = 'tls';
//$mail->Port = 587;
For other providers you have to create a mailbox with your domain:
$mail->isSMTP();
$mail->Host = localhost;
$mail->SMTPAuth = true;
$mail->Username = 'example#yourdomain.com';
$mail->Password = 'password';
//$mail->SMTPSecure = 'tls';
//$mail->Port = 587;
I need to connect to the GMAIL SMTP server with email and password, without sending email and then receiving 200 OK.
I using the code PHPMailer:
$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 = "myuser#gmail.com";
$mail->Password = "password";
$mail->SetFrom("");
$mail->Subject = utf8_decode("My subject");
$mail->Body = "hello";
$mail->AddAddress("destination#gmail.com");
$mail->Body = template('emails/reset-password', compact('comentario'));
if ($mail->Send()) {
$mail->ClearAllRecipients();
$mail->ClearAttachments();
}
My script is sending email, I would just like to validate the authentication.
PHPMailer itself isn't much use for this as it's all about the sending. However, the SMTP class that's part of PHPMailer can do this just fine, and there is a script provided with PHPMailer that does exactly as you ask. I'm not going to reproduce the script here as it just creates maintenance for me!
The script connects to an SMTP server, starts TLS, and authenticates, and that's all.
I am sending emails using PHPMailer and through my gmail account with SMTP. It all works except when there is an & in the subject, then in my inbox the subject has &
Any way to make this not happen? I've tried setting the charset and encoding the subject.
My code is below
$mail = new PHPMailer();
$mail->IsSMTP(); // telling the class to use SMTP
$mail->CharSet = 'UTF-8';
$mail->SMTPDebug = false;
$mail->SMTPAuth = true; // enable SMTP authentication
$mail->SMTPSecure = "tls"; // sets the prefix to the servier
$mail->Host = "smtp.gmail.com"; // sets GMAIL as the SMTP server
$mail->Port = 587; // set the SMTP port for the GMAIL server
$mail->Username = "myusername#gmail.com"; // GMAIL username
$mail->Password = "password"; // GMAIL password
$mail->SetFrom('from#somesite.com', 'From Person');
$mail->AddReplyTo("from#somesite.com", "From Person");
$mail->Subject = 'An example with a & in the middle';
$mail->MsgHTML('Some text to send');
$mail->AddAddress('myusername#gmail.com');
$mail->Send()
Thank You
Try using this code, let me know if it helps.
$mail->Subject = "=?UTF-8?B?".base64_encode($_POST['subject'])."?=";
I have following system setup
Windows XP Service pack 2
WAMP 2.0
PHP 5.3
I've configured my php.ini file with the following:
smtp=smtp.gmail.com
smtp_port=25;
and my PHP code is
<?php
mail('alagar.pandi#gmail.com','test subject','test body');
?>
The error I'm getting is
Warning: mail() [function.mail]: SMTP server response:
530 5.7.0 Must issue a STARTTLS command first.
4sm389277yxd.16 in C:\wamp\www\limosbusesjets\test.php on line 5
Any suggestions?
I have always used PHPMailer for all my mailing needs.
It has built in support for GMail as a server (and it's free)
I think your issue is that you are trying to use PHP's mail settings and not PHPMailer's
Make sure you have the following set:
$mail = new PHPMailer(); //Setup the mailer
$mail->IsSMTP();
//$mail->SMTPDebug = 2;
$mail->SMTPAuth = true; //enable SMTP authentication
$mail->SMTPSecure = "ssl"; //sets the prefix to the servier
$mail->Host = "smtp.gmail.com"; //sets GMAIL as the SMTP server
$mail->Port = 465; //set the SMTP port
$mail->Username = $guser; //GMAIL username
$mail->Password = $gpwd; //GMAIL password
$mail->AddReplyTo($fromAddress,$fromName);
$mail->From = $guser;
$mail->FromName = "Your name";
$mail->Subject = $subject; //E-Mail subject
$mail->AltBody = $bodyAlt; //Text Body
$mail->WordWrap = 50; //set word wrap
$mail->Priority = $priority; //Mail priority
$mail->MsgHTML($ebody);
Mail via Google needs to be run through SSL.
There are a lot of arcticles on subject, you might find this useful: http://deepakssn.blogspot.com/2006/06/gmail-php-send-email-using-php-with.html