I have an SMTP question. I have created a PHP script to send out emails. The requirement is that I need to send email from 'email1#example.com' but I need replies to come to 'email2#example.com'
I have added email2#example.com in the reply-to header field. The only problem I am having is that when someone receives the email and clicks on the reply button, both email1#example.com and email2#example.com are being shown in the TO field.
Is there any way that I can have email1#example.com removed from the TO field and only show the email address that was specified in the reply-to field?
I am using PHPMailer and the code is below:
$this->phpmailer->IsSMTP();
$this->phpmailer->Host = $server;
$this->phpmailer->Port = $port;
$this->phpmailer->SetFrom($fromEmail, $fromName); //this is email1#example.com
$this->phpmailer->AddReplyTo($replyEmail,$fromName); //this is email2#example.com
$this->phpmailer->Subject = $subject;
$this->phpmailer->AltBody = $msgTXT; // non-html text
$this->phpmailer->MsgHTML($msgHTML); // html body-text
$this->phpmailer->AddAddress($email);
Try:
$this->phpmailer->IsSMTP();
$this->phpmailer->Host = $server;
$this->phpmailer->Port = $port;
$this->phpmailer->AddReplyTo($replyEmail,$fromName); //this is email2#example.com
$this->phpmailer->SetFrom($fromEmail, $fromName); //this is email1#example.com
$this->phpmailer->Subject = $subject;
$this->phpmailer->MsgHTML($msgHTML); // html body-text
$this->phpmailer->AddAddress($email);
Try setting AddReplyTo() first before SetFrom. phpmailer needs to change this behavior. It adds the from address to the reply-to field. If you set reply-to first before the from address, it will not be able to add your from address to the reply-to header.
From a google search and first result
Adding a Reply-To Address ^
By default the Reply-To address will be the FROM address unless you specify otherwise. That is simply E-Mail client intelligence. However, you can have the E-Mail come from one E-Mail address and any replies go to a different one. Here's how:
$mailer->AddReplyTo('billing#yourdomain.com', 'Billing Department');
NOTE:
You can have multiple Reply-To addresses, just duplicate the line in the previous code example and change the E-Mail address on each line.
You will need to add this line before your from address. Please check out this for the solution to the same problem.
Following these examples, your code should look like
$this->phpmailer->IsSMTP();
$this->phpmailer->Host = $server;
$this->phpmailer->Port = $port;
$this->phpmailer->AddReplyTo($replyEmail,$fromName); //this is email2#example.com
$this->phpmailer->SetFrom($fromEmail, $fromName); //this is email1#example.com
$this->phpmailer->Subject = $subject;
$this->phpmailer->AltBody = $msgTXT; // non-html text
$this->phpmailer->MsgHTML($msgHTML); // html body-text
$this->phpmailer->AddAddress($email);
Related
I am working in laravel 4.2 version and sending email for marketing purpose. But the problem is that when i send email to many users then all the users can view the email addresses of other users.
I am sending email using laravel queue method and here is my working code
$emails[] = 'someonea#gmail.com';
$emails[] = 'someoneb#gmail.com';
$emails[] = 'someonec#gmail.com';
$emails[] = 'someoned#gmail.com';
$emails[] = 'someonee#gmail.com';
if(!empty($emails)){
$data['content'] = $message;
$admin_email = UserHelper::$driver['admin_email'];
$site_title = UserHelper::$driver['site_title'];
Mail::queue('emails.market',$data,function($mail)use($emails,$subject,$data){
$mail->to($emails);
$mail->subject($subject);
$mail->from($emails);
});
}
when i receive an email then i am also able to see the email all other users in to of inbox.
Please help to resolve this issue.
Thanks in advance
You can try bcc to send the same email to other users. When you use BCC, any recipients on the Bcc line of an email are not visible to others on the email.
Mail::queue('emails.market',$data,function($mail)use($emails,$subject,$data){
$mail->to($firstEmailAddredd);
$mail->to($restAllEmailAddredd);
$mail->subject($subject);
$mail->from($emails);
});
Not tested this thing, but sure that this will help you!
I want to send unique emails to multiple people (could be 1, could be 100) using PHPMailer.
$notifyemailscontent is an array that holds all the emails and names (again, could be 1 could be 100).
This below works, but I'm curious if there is a better way to do this. It seems to take a while even when there's only like 5 emails. Is there a quicker, more efficient way to do this type of thing? Or does it simply take this long if you're sending multiple emails?
/// Send notification email
require 'phpmailer/PHPMailerAutoload.php';
$mail = new PHPMailer;
$mail->setFrom('admin#mydomain.com', 'MyDomain');
$mail->addReplyTo('admin#mydomain.com', 'MyDomain');
$mail->isHTML(true); // Set email format to HTML
$mail->Subject = "FYI, there's a new entry!";
foreach($notifyemailscontent as $email => $name) {
$mail->addAddress($email, $name);
$mail->Body = "Hi $name!<br><br>
We're just letting you know that there is a new entry. To see it, click the link below:<br><br>
<a style='background: blue; color: white;' href='http://myfulldomain'>the pool name</a>
";
$mail->AltBody = "";
$mail->send();
$mail->ClearAddresses();
}
I am building a quote system, the quote system sends out the quote to multiple people with a personalised message via email. I am using the following code to do so:
$mail = new PHPMailer();
$mail->AddReplyTo("myAddress#domain.com", "Company");
$mail->SetFrom('quotes#company.com', 'COMPANY');
// Set each of the recipients
$users = $quote->GetClients();
foreach($users as $user)
{
$mail->AddAddress($user["Email"], $user["Name"]);
}
$mail->Subject = "Hello" . $users[0]["Name"];
$body = "This is your personal Email";
$mail->MsgHTML($body);
$mail->Send();
The problem being is that, when I send this email, it sends to all the recipients that it should, but it includes all of the recipients names. Whereas, I just want to display for that particular person. I.e. If I get an email, it would be: "Hello Phorce, This is your Personal Email" but instead I get "Hello {user1} {user2} {user3}" and this is not what I want.
Is it possible to do what I am trying to do using PHPMailer?
I am sending mail via PHP Mailer. http://phpmailer.worxware.com/
I want to be able to set the From to one emailand the REPLY-TO to another email and the RETURN-PATH to yet another.
Mainly.. I want the bounced emails to go to something like BOUNCEDemails#bademail.com
I was hoping the RETURN PATH could do this.
And if a user who gets the email I don't want them to see its from BOUNCEDemails etc.. to I want to give them an option to reply to a real email address.
I need the bounced emails tho to go to a seperate email because I don't want the REPLY TO to get many bad emails. etc..
HERE IS WHAT I HAVE: Does Not work
$mail->AddAddress('ed#RealEmail.org', 'John Doe');
$mail->AddReplyTo('replytoMe#email.com', 'Reply to email');
$mail->SetFrom('mailbox#email.com', 'From Name and Email');
$mail->AddCustomHeader('Return-path: BOUNCEDemails#bademail.com');
The code above replies to SetFrom and sends all bounces to SetFrom. Any ideas how to separate the two? Thanks
the correct way to set this (as of july 2013) is by using:
$mail->ReturnPath='bounce_here#domain.com';
the phpmailer source contains the following, which is fairly self explanatory:
if ($this->ReturnPath) {
$result .= $this->HeaderLine('Return-Path', '<'.trim($this->ReturnPath).'>');
} elseif ($this->Sender == '') {
$result .= $this->HeaderLine('Return-Path', '<'.trim($this->From).'>');
} else {
$result .= $this->HeaderLine('Return-Path', '<'.trim($this->Sender).'>');
}
You may use
$mail->AddReplyTo('name#yourdomain.com', 'First Last');
$mail->AddReplyTo('replytoMe#email.com', 'Reply to email');
$mail->AddAddress('ed#RealEmail.org', 'John Doe');
Notice the order! AddReplyTo has to be BEFORE AddAddress!!!
I'm trying to get Zend_Mail to send an encapsulated message - as though it's forwarding an email.
$attachedContent = "<h1>H1 Email</h1>";
$emailContent = "<h1>Email Content>";
$mail = new Zend_Mail();
$mail->setBodyText('text content');
$mail->setBodyHtml($emailContent);
$mail->setFrom('kieran#fromz.com.au', 'GAS');
$mail->addTo('kieran#fromz.com.au', 'GAS');
$at = $mail->createAttachment($attachedContent);
$at->type = 'message/rfc822;
name="forwarded message"';
$at->disposition = Zend_Mime::DISPOSITION_INLINE;
$at->encoding = Zend_Mime::ENCODING_7BIT;
$mail->setSubject('Test');
$mail->send();
Mail clients are getting the email, rendering the normal HTML content, and displaying the forwarded message and rendering its contents, however, it's formatting like:
<h1>Email Content</h1>
Can you see what I'm doing wrong? I've not found anything online, and have tried my best to copy the formatting from looking at email source.
Cheers,
Kieran
maybe these lines are causing it??
$attachedContent = "<h1>H1 Email</h1>";
$emailContent = "<h1>Email Content>";