I wanna subscribe my website newsletter members to my Google Group automatically.
I try send email to mygroupname+subscribe#googlegroups.com with subject & body "subscribe" by PHP Mail function from user email. but not any result and subscription resquest in my group.
$phpMailSender = new PHPMailer();
$phpMailSender->CharSet = "UTF-8";
foreach($users as $user) {
$phpMailSender->ClearAddresses();
$phpMailSender->From = $user['email'];
$phpMailSender->FromName = $user['email'];
$phpMailSender->AddReplyTo($user['email']);
$phpMailSender->addAddress('mygroupname+subscribe#googlegroups.com');
$phpMailSender->Subject = 'subscribe';
$phpMailSender->Body = 'subscribe';
$result = $phpMailSender->send();
if($result)
echo "Subscription email Sent for user# " . $user['email'] . "\n";
else
echo "Subscription email failed for user# " . $user['email'] . "\n";
ob_flush();
flush();
}
Can any one help me!
Whilst looking at a question in the hMailServer forum.
The fellow there gives some ideas on how to do this (albeit, no code), but there are good considerations.
But there is a bit more involved than just subscribing the user to the list. You also need to validate the email address the user provides so that people don't enter other people's email addresses. This would be done by sending an email to the user and asking him to confirm his subscription. When he clicks the link to confirm, he goes to your webpage that is keyed to a database entry somewhere, and then the email gets added to the list in a manner that you are attempting.
But check out the link I provide above for a few more considerations.
Here is another similar thread.
As for code, there is a snippet here.
This thread also has some php code, similar to yours - you should look at this.
Related
My PHP app allows users to invite members by e-mail. I want to inform the inviting user if there was a problem with the invitation, for this case when I got a back Non-Delivery Report.
Before sending the mail with PHP mailer I am defining the messageID like this:
$mail->MessageID = unique#domain.com
This custom setted ID gets also written in the database. This works fine.
Next I am observing the mailbox from which the mails were sent with the following script for test purposes:
$mbox = imap_open("{imap.example.org:143}INBOX", "username", "password")
or die("can't connect: " . imap_last_error());
$MC = imap_check($mbox);
// Fetch an overview for all messages in INBOX
$result = imap_fetch_overview($mbox,"1:{$MC->Nmsgs}",0);
foreach ($result as $overview) {
echo "#{$overview->msgno} ({$overview->references}) - From: {$overview->from}
{$overview->subject}\n";
}
imap_close($mbox);
When answering a email by hand this script perfectly gives back the before set message id as reference. So if this reference fits to a message id in the database I am able to inform the user that someone replied to their mail.
However when there comes back a bounce mail the references property is empty. Is there a straight forward to get the message id of the initial mail?
Setting up a different reply-to address is no option because I want to send an user friendly notification with some troubleshoot information
I am currently building a system and I am using Google OAuth with that Google auto emailer code.
I included this block of code for you to visualize what I wanted to happen.
<?php
include_once "mailer.php" ;
$mail = new Mailer();
$email = "sample#gmail.com";
$name = "Daniel";
$subject= "testing";
$message = "Why so serious??";
$mail->mail($email,$subject,$message);
if(!$email){
echo " mail not sent " ;
}
else if ($email) {
echo "mail sent! " ;
}
Their provided code would usually ask for the password of the account. You actually have to type your password in the code, which is obviously quite dangerous. And the email being used there will be the same email account used when the system generates automated email. (which means only one email address will be used in the auto-emails regardless whoever is logged in).
What I wanted to do was to use the email address of whoever is logged in when sending an auto email.
Why not use http://framework.zend.com/manual/1.12/en/zend.mail.introduction.html . The folks at Google are secular kings for those of us in programming, but I love Zend Framework because it is easy and uses PHP's innate mail send abilities. Try it out, I think it may fit the bill.
I'm a newbie in PHP. My goal is to send an email to the user registered in my system.
Here is my code:
$msg= " Hi $gen./$lName, copy and paste this code in order to activate
your account copy and paste this code:$num" ;
$email = "$emailadd";
$name= "GoodFaith Network Marketing Inc.";
$subject = "Account Activation";
$message = wordwrap($msg,70) ;
$sender = "cjoveric#myalphaedge.com";
$mail_header="From: ".$name."<". $sender. ">\r\n";
$sendmail=mail($email, $subject,$message, $mail_header );
I was able to send an email, but my problem is I want to know if the user's email address exists in Yahoo, GMail or other mail services.
Is there any way I could filter out invalid emails?
Use SMTP mail the best and easy to use SMTP.
$mail->IsHTML(true);
$mail->From="admin#example.com";
$mail->FromName="Example.com";
$mail->Sender=$from; // indicates ReturnPath header
$mail->AddReplyTo($from, $from_name); // indicates ReplyTo headers
$mail->AddCC('cc#phpgang.com.com', 'CC: to phpgang.com');
$mail->Subject = $subject;
$mail->Body = $body;
$mail->AddAddress($to);
if(!$mail->Send())
{
$error = 'Mail error: '.$mail->ErrorInfo;
return true;
}
else
{
$error = 'Message sent!';
return false;
}
Not really. About the best you can do is send an email and see if the user responds to it.
Doing a regex check on email address can be frustrating for some users, depending on regex. So, I recommend to skip your regex test and just send the verification email with a confirmation link -- anything else will leave your application brittle and subject to breakage as soon as someone comes up with a new DNS or SMTP extension. It's best to get that dealt with when their paying attention.
For example:
-a confirmation code that needs to be filled in your website
-a link, going to your website, that needs to be visited
And still it is uncertain whether the email is existing afterwards, as it is easy to simply create a temporary email to pass the validation and delete it afterwards.
Instead of validating email addresses you can use the Google API to let your users sign in using their account. It is also possible to use OpenID on a similar way. Though, even this is not 100% perfect. But heay, nothing is 100%. We all try to make is work as we want as much as possible. That's it.
PS: ICANN is expected to approve UNICODE domain names Real Soon Now. That will play merry hell with Regex patterns for email addresses.
I have an application built in CodeIgniter. I needed some help with the following email related tasks. Please note all emails will require SSL.
1) Send email to congratulate and welcome the user to the site
2) Send an email to confirm a user account has been deleted should they choose to leave.
3) Send an email to alert the user for a request sent to them from another user.
4) Set up and send an email for "forgot username" and last but not not least
5) Send an email to reset password in case the user can't remember how to login.
Thanks for your help, appreciate it.
function signup(){
$data = array(
'sign_up_mail'=>'Welcome and thanks for joining...'
);
$htmlMessage = $this->parser->parse('user/email/signup_html', $data, true);
$txtMessage = $this->parser->parse('user/email/signup_txt', $data, true);
#send the message
$this->email->from('test#gmail.com', 'test app');
$this->email->to($this->input->post('email_address'));
$this->email->subject('Account Registration');
$this->email->message($htmlMessage);
$this->email->alt_message($txtMessage);
$this->email->send();
}
Would you use this listed below as the method for changing the message within the various emails?
data['message'] = "Hey there, you've got a follower request!";
$email = $this->load->view('email/template', $data, TRUE);
I presume this method works for simple things like user welcome and alerts etc. How would I go about connecting a process to resetting a username/password or confirming a deletion? How do you connect the email process with manipulating data in the db?
From your question, I think you are looking for some kind of authentication related tasks. If so, there is an authentication, library in codeigniter, that provides complete authentication system. Have a look, it it is useful to you. http://konyukhov.com/soft/tank_auth/
When a user subscribes to my newsletter via their email address, using php, how would I send them an 'Activation Link' via email to confirm it is their email address and not a fake one.
so at the moment I have
PHP:
<?php
$to = "recipient#example.com";
$subject = "Hi!";
$body = "Hi,\n\nHow are you?";
if (mail($to, $subject, $body)) {
echo "<p>Message successfully sent!</p>";
} else {
echo "<p>Message delivery failed...</p>";
}
?>
I guess i would change the $body to this:
$body = "Please click the link to activate your email \n
http://www.activationlink.com?";
How would I make it so that if a user clicked that link it would add their details to the Mysql database recognising they are a legitimate subscriber?
Any help or suggestions appreciated. Thanks
Quick google search result
http://www.learnphponline.com/scripts/email-activation-for-php-forms
basically you need to create a subscriber table and have a boolean flag call verified, of coz store the email address in that table
ok i would try to suggest you some thing which happens while signup on most of sites today.
what happens is that when you enter your user name and password it says
"An email is sent to your location.....(something like this)" what we do is that before sending email we save that username and password in the DB but make there status inactive.
So when users click the link and they get the relevent site, all needed then is to verify the code and change status.
So some what similar you have to add the email to your DB and then send some email. In that case it will be easy for you handle your current problem.
Use the http://en.wikipedia.org/wiki/Message_authentication_code (MAC) approach. You should have a secret key. Use the key and user's email to generate SHA1 hash. Then produce an activation link which includes user's email and the hash. After you receive a click from the link, you do the same - use the same secret key, take the email from the link, generate hash and compare it with provided in the link. If it does match, then it means the e-mail address is confirmed.
Also, together with email you could include some more info (e.g. timestamp to make links expire-able), all info could be authenticated with the MAC approach.
You don't need store any information in a database, as in answer from #Tommy.