Jump to content

sreyan32

New Members
  • Posts

    1
  • Joined

  • Last visited

sreyan32's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Hello, I am using the latest version of PHPMailer to try and send mails. The SMTP server is configured to use the Gmail SMTP. Now the problem is that when I am sending mails to a person with a Gmail account there seems to be no problem but when I am sending my mail to someone with a non Gmail account for example Yahoo. The mail never reaches(I have checked the SPAM folder). My PHP Mailer setup is as follows-: <?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 link to activate your account-:<br /><a href='http://www.google.co.in'>Click Here !! </a><br />END OF MESSAGE.</body></html>"; $body = eregi_replace("[\]",'',$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 = "foobar@gmail.com"; // GMAIL username $mail->Password = "foobar"; // GMAIL password $mail->SetFrom("foobar@gmail.com", "foo"); $mail->AddReplyTo("foobar@gmail.com", "foo"); $mail->Subject = "foo bar"; $mail->AltBody = "To view the message, please use an HTML compatible email viewer!"; // optional, comment out and test $mail->MsgHTML($body); $address = $_GET['email']; $mail->AddAddress($address); if(!$mail->Send()) { echo "Mailer Error: " . $mail->ErrorInfo;} else { } ?> <html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"><title>domail</title></head> < body></body></html> My Questions are as follows-: Do I have to reconfigure my SMTP every time I send my mail to a different account ? For example if I have to send it to a Yahoo account do I have to use the Yahoo SMTP or when I send my mail to a Rediff account do I have to use the Rediff SMTP ??PHPMailer doesn't report any errors, it just says that it sent the message but the message never arrives. Can't I just use one SMTP and send mails to any account ? I am using WAMP server on my PC to run my Apache Web Server. Will this create problems in sending mails even if PHPMailer is configured correctly ? Is it necessary to add a name with the receiver address in the line-: $mail->AddAddress($address); Do I have to write it like this $mail->AddAddress($address,"Receiver Name"); Since my mail will be sent to anyone signing up specifying the correct receiver name every time will be a little difficult to do. I am getting an error on the line-: $body = eregi_replace("[\]",'',$body); The problem is that the function eregi_replace() has become deprecated. According to the php.net documentation I have to use preg_replace() with the " i " switch. But since I am beginner to PHP and regular expression I can't figure out how to do that. Can someone give the code which accomplishes the same task as the line above using preg_replace. Thank You.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.