I am trying to edit contact.php file of opencart so that it send email to multiple email id when a contact form is filled.
$mail->setTo($this->config->get('config_email'));
tried
$mail->setTo($this->config->get('config_email'),'manager#domain.com','ceo#domain.com');
Above edit did not work. How to hard code additional email ids? in such way that reply all works when replied by anyone of recipient from his email box.
If you check the source code of the SMTP adapter for Opencart, you can see that the to address accepts an array (as follows):
if (is_array($this->to)) {
$to = implode(',', $this->to);
} else {
$to = $this->to;
}
So, you could update your code as follows and pass the addresses in as an array:
$mail->setTo(array(
$this->config->get('config_email'),
'manager#domain.com',
'ceo#domain.com'
));
Related
I have a simple php mail script which will send emails.
The problem is while sending it is displaying sendername <senderemail#domain.com>
I have given in the code as $headers = "From: $name <$senderEmail>";
I want to display only name and not email address of the sender.
How do I do that?
Here is the program in its entirety.
<?php
if($_POST["submit"]) {
$recipient=$_POST["senderemail"];
$subject=$_POST["subject"];
$name=$_POST["name"];
$senderEmail=$_POST["email"];
$city=$_POST["city"];
$headers = "From: $name <$senderEmail>";
$mailBody="$city\n";
$process=explode(",",$recipient);
reset($process);
foreach ($process as $to) {
mail($to,$subject, $mailBody,$headers);
}
$thankYou="<p>Thank you! Your Message has been sent.</p>";
echo 'Thank you! Your Message has been sent.';
}
?>
A From header containing both name and address should be formatted like this:
From: User Name <user#example.com>
If you don't provide a name, it will display the email address.
PHPMailer has built-in support for creating this header correctly for you via the From and FromName properties, and the setFrom method (it doesn't matter which you use):
$mail->setFrom('user#example/com', 'User Name');
or
$mail->From = 'user#example/com';
$mail->FromName = 'User Name';
Your generated message already seems to contain the user's full name in the From: header (assuming $name is the human-readable name). How this is displayed by any individual user agent is no longer in your hands. Very often, it will display both parts regardless; or only shorten to the human-readable name if the sender's email address is in the recipient's address book. (Thunderbird takes this a step further and displays the information from the address book rather than the actual information in the message!)
One common problem is if the generated message has a different Sender: header; often, this will cause the recipient's user agent to display more than just the usual full name. Your question doesn't mention this, nor does it show one of the generated messages; but perhaps this will help you find a solution.
I have already my own PHP Form working.. If someone fills my FORM and they will submit it.
I will recieve a email with all the filled details. Like: Name, Firstname, Email, Tel etc.
But i want that if someone will submit the form, they will recieve automaticly a Custom Email.
Example: User will fill all the details in the form and press send.
Then he will receive a email from me like: Hai Ben, Thanks for submitting my form.. I will contact you a.s.a.p
Right now the form is only sending MY an email with al the details..
But i want that Ben will get a confirmation e-mail. So if Ben will fill in as email: info#ben.com then the confirmation email has to go there
Show us your code so that we can suggest you, how to modify it to get what are you trying to achieve. There will be many different ways to do things, and the best would depend on how rest of your codes are.
Just like you are calling mail function in your code to email yourself with the details, you can call the mail function to send him an email.
Also, you dont hardcode info#ben into the script. You can just collect his email from the POST variables.
Sample, assuming your form works on POST and the email is stored in email in the post variables.
$send = mail($_POST['email'], $subject, $messagebody, $header);
Now do the bit of tinkering you would need to get it working with your script.
Here is the example code for sending email:
$from = $_POST['email'];
$to = 'your-email#email.com';
$subject = "Title here";
$messagebody = <<<EMAIL
Thanks for submitting my form..
I will contact you a.s.a.p
EMAIL;
$header = "From: $from";
$send = mail($to, $subject, $messagebody, $header);
I am using Class MailerPHP to send emails on the website. Actually is working perfect as it have to work but there is some strange stuff that i can not figure out why is like this.
1. I have an array of address that i am sending emails, the array is like this:
$email = new sendEmail();
$_ADMIN_EMAIL = array('first_email', 'second_email', 'third_email');
$email->setEmail($_ADMIN_EMAIL);
The problem is when is sending emails, is sending 3 emails:
1. sending to first_email
2. after sending to first_email and second_email
3. and at the end sending to first_email, second_email and third_email
I would like to send only one to all 3 and do not send 3 times email, i do not understand why is sending like this.
2. And second problem is i am using my Google account to connect to the SMTP to send emails, and i do not know why in the TO field of the email is showing my gmail address that i connect to the SMTP, i setup which address to show there and is showing + my gmail account:
I have this configuration only and i didn't put anywhere else my gmail account only for SMTP connection:
public $Username = 'my_gmail_account_to connect_to_smtp';
public $Password = 'my_gmail_account_password';
The result of this when i get emails is first email that i setup to show for reply + my_gmail_account_to connect_to_smtp, i need to take out my_gmail_account_to connect_to_smtp from the email that the user will not see it.
If you need for information about the code i use please let me know i will put.
All the code that i send email:
$_ADMIN_EMAIL = array("first_email", "second_email", "third_email");
$email2 = new sendEmail();
$email2->setSubject("Subject");
$email2->setUserName($_USER['name']);
$email2->setMT4Account($_USER['login']);
$email2->setDate($_USER['date']);
$email2->setAmount($_USER['amount']);
$email2->setCurrency($_USER['currency']);
$email2->setRegisteredBankAccount($_USER['type']);
$email2->setBankAccountName($_USER['card']);
$email2->setTemplate('template_for_the_email');
$email2->setEmail($_ADMIN_EMAIL);
echo $email2->send();
Try this:
$_ADMIN_EMAIL = array('first_email', 'second_email', 'third_email');
foreach($_ADMIN_EMAIL as $ademail)
{
$email->setEmail($ademail);
}
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 a contact form, the entire markup for which (other than the javascript) can be found here. The form sends an email with the information input by the user to whichever email is defined under to_email in an options panel.
I am using this form in WordPress and would like to have the IP address of the person filling out the form attached to the message. I tried incorporating code from this post but I'm a newbie to PHP and can't seem to incorporate it correctly (to actually send it with the rest of the message).
If anybody can offer help as to what code I should include and where I should include it to display the sender's IP address I would greatly appreciate it.
$body = "Name: $name \n\nEmail: $email \n\nComments: $comments";
replace with
$body = "Name: $name \n\nEmail: $email \n\nComments: $comments \n\nIP: ".$_SERVER['REMOTE_ADDR'];
I know this is a pretty old question, but I though about helping who arrives on this one.
First, I would recommand Contact form 7 plugin for creating a form with wordpress.
It could look like this at the creation of the form:
you add in the body of your message (in the screenshot in the right column "Message Body") the following short code :
[wpcf7.remote_ip]
Your message would (without modification) look like:
From: [your-name] <[your-email]> Subject: [your-subject]
Message Body: [your-message]
Sent from: [wpcf7.remote_ip]
--
This e-mail was sent from contact form on Testing (heep://localhost:8888/wordpress)
this will print the user IP into the email you'll receive.
Then in your post, you integrate the short code given into the page (like):
[contact-form-7 id="1056" title="Sample Form"]