/    Sign up×
Community /Pin to ProfileBookmark

PHPMailer How to send mails to anyone ?

Hello,
I am a beginner to PHP and Web 2.0 development in general. I am making a project in which where once a user sign’s up he/she will get a confirmation email in his/her inbox and must confirm the mail id by clicking on a link. Pretty standard stuff. Now I am using the latest version of PHPMailer to do this. I am connected to the gmail smtp, and the settings are as follows-:

[CODE]$mail->Host = “smtp.gmail.com”; // SMTP server
$mail->SMTPDebug = 2; // enables SMTP debug information (for testing)
// 1 = errors and messages
// 2 = messages only
$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 = “[email protected]”; // GMAIL username
$mail->Password = “foobar”; // GMAIL password[/CODE]

Now when I am sending mails to a person who has a Gmail account it is working fine. But the moment I am sending any mail to someone with a Yahoo account, the mail doesn’t seem to reach the client. Do I have to reconfigure PHPMailer again to say the yahoo SMTP service. [B]Can I send mails to yahoo through the GMail SMTP ??? Or do i have to reconfigure again each time I have to send mail to a different service provider ??[/B] Thank You.

to post a comment
PHP

3 Comments(s)

Copy linkTweet thisAlerts:
@NogDogApr 29.2013 — Have you checked the spam folder on the target Yahoo email account? (And yes, the SMTP server should be able to send the email anywhere on the net.)
Copy linkTweet thisAlerts:
@sreyan32authorApr 30.2013 — Have you checked the spam folder on the target Yahoo email account? (And yes, the SMTP server should be able to send the email anywhere on the net.)[/QUOTE]

Yup Checked the spam folder. No mail has reached.
Copy linkTweet thisAlerts:
@sreyan32authorApr 30.2013 — My entire PHPMailer mail setup is as follows-:
[CODE]<?php
require_once('mailer/class.phpmailer.php');
//include("class.smtp.php"); // optional, gets called from within class.phpmailer.php if not already loaded

$mail = new PHPMailer();

$body = "<html><head></head><body>
<strong>This is a System generated message. PLEASE DO NOT REPLY TO THIS MAIL.</strong>
<br />
Click on the following ling to activate your account-:
<br />
<a href='http://www.google.co.in'>Click Here !! </a>
<br />
END OF MESSAGE.
</body></html>";
//$body = preg_replace("[]i",'',$body);

$mail->IsSMTP(); // telling the class to use SMTP
$mail->Host = "smtp.gmail.com"; // SMTP server
$mail->SMTPDebug = 2; // enables SMTP debug information (for testing)
// 1 = errors and messages
// 2 = messages only
$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 = "[email protected]"; // GMAIL username
$mail->Password = "foobar"; // GMAIL password

$mail->SetFrom("[email protected]", "India Indigenous");

$mail->AddReplyTo("[email protected]", "India Indigenous");

$mail->Subject = "India Indigenous Account Activation";

$mail->AltBody = "To view the message, please use an HTML compatible email viewer!"; // optional, comment out and test

$mail->MsgHTML($body);

$address = "[email protected]";
$mail->AddAddress($address);

if(!$mail->Send()) {
echo "Mailer Error: " . $mail->ErrorInfo;
} else {
echo "Message sent!";
}


?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>domail</title>
</head>

<body>
</body>
</html>[/CODE]


The above configuration works fine for Gmail mails but I can't send mails to Yahoo. Do I have to change the "$mail->Host " parameter to the Yahoo SMTP ?? It is set to Gmail SMTP.
×

Success!

Help @sreyan32 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.25,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...