PHP - trying to send an email but server don't let it - php

I am making a contact form in php using mail function, but the hosting is saying that I have to put into parameter 'from' email only with domain name which is the same like in the hosting. But I need to put in the 'from' email from form. Is there any way how to avoid this? I don't want to use external scripts. Thanks for any help.

you cant send emails with email adresses
that arent from your server because of security reasons otherwise you could send an email from zuckerberg#facebook.com or something similar.
use the answer to param to add the contact form email and put something that is from your server into the from

Related

Mail-Tester.com : Freemail in Reply-To, but not From

I can not solve the problem of spam. I only have 7.6 / 10 on Mail-Tester.com.
I specify that I use postfix, and I need it only for the sendings.
Here is my result: https://www.mail-tester.com/web-n0z33
Mail-Tester.com tells me that the problem come from ReplyTO… But I am obliged well to use ReplyTO so that I can click "to answer" when I receives an e-mail sent since a form of contact of my Web site.
I also specify that FROM I put an email address #my-domain.fr. Because if in FROM I directly put the email address of the visitor who fills my contact form I have even worse errors with Mail-Tester.com.
And here is my PHP code:
$mailer = new Mailer();
$mailer->setFrom(contact#mondomaine.fr)
->setReplyTo('emailexemple#gmail.com')
->setTo($_GET['mail'])
->setSubject($data['subject'])
->setBody('front/specific-page/contact/contact-html', $data)
->addBodyText('front/specific-page/contact/contact-text', $data);
var_dump($mailer->send());
I use SwiftMailer with the driver at 'mail', but I created my own adapter so that's why I have this code. But it is easy to understand.
How to solve my problem? How to have a 10/10 rating with Mail-Tester.com?
Thank you very much.
I am sitting with the same problem. Currently, from what I have found on the net, you can not "fix" this. However, there are some ways to help resolve it. Here are a few options you can try, based on these references:
Ref 1
Ref 2
They both say the following:
"Wrap mail messages in HTML tags to avoid spam filters."
The FROM address must be those from the visitor who uses the contact form. How would you else respond to the email? And why even use a tool to test the spam score of an email sent with a contact form? You are the only receiver of those emails.
The 10/10 rating with Mail-Tester.com is telling you only, that Mail-Tester thinks, that your email is just fine. I would not rely too much on this tool. All email service providers have anyway own spam filters and will handle your email as they see right. For instance, if you test your email with another tool like https://www.emailchecky.com, you will mostly see other results and found errors.
Or make another test:
You can send the email also to a Gmail address and see if the email is landing in the main inbox or the spam folder instead. Gmail has the most aggressive spam filters and rules I know. If your email will pass these rules and filters you can be proud of your email.

Send emails on gmail

I am wondering if there is a way to send a quick email to my leads on gmail. I want to send each message to store them in the sent folder, I know that it can be done by create each compose message but it will give me the hard work to send the emails to each user and I don't like to use BCC because when I receive the emails from the users, I will only see one message in my inbox. I want to receive each email from each user.
Example:
http://oi57.tinypic.com/ztiy5f.jpg
I don't like to receive the email like this:
http://oi60.tinypic.com/4gl11e.jpg
Is there a way to do that through on VB6, PHP, gmail or whatever it is?
Sending mail using PHP, for example. It's not as easy as it used to be.
The sending part, is trivial. Most of the time folks use the mail command, pass parameters to it, and voila.
However, with today's overachieving spam filtering via ISPs, etc. -- Chances are very good that your email might not ever get received at its intended address. It might get there, most likely will be sent to spam, and can have several hours of delay.
The best way to send email, as far as I know, is with SMTP email in PHP. PHP mail vs SMTP

Send notification e-mail when php form is sent

If a php form is completed and send with the submit button, how can I send an e-mail together to an administrator for example? I want to sent the user's name who created a new user through a form
The creator is coming from $_SESSION['username'].
Can I use the PHP mail function to do this?
If mail is correctly set up in your php.ini file you can use this.
You can also install and use PHPMailer if you want access to a full SMTP server or a lot more fine control over how your email is built.
Yes you can use the mail function. You just have to send the input field value's from the form in the mail function.
Yes. I've posted a rather simple example on SO before which you can take a look at, also there are numerous examples elsewhere on the internet that provide you details for the task.

What is an Auto-Responder?

I'm a noob and seriously confused. I built a form for my website with a php script that validates and sends an email to me when someone fills it out. So, what is an auto-responder? Do I incorporate that some how with my php script, or do I not need the php script at all if I use an auto-responder? Thanks in advance
Autoresponder is automatic mail shooted back to the origin email box , it may contains information like "Thank you for email and will get back to you soon". It can be configured at the mail provider or you can also do the coding for the same. As any user submit the form and he has valid mail , just read his email id in the last and send him the thanks email immediately . Later you can see his feedback and reply again.
An autoresponder is used for automatically sending email notifications when something happens, like you just subscribed to something. Some web hosting companies such as GoDaddy offer autoresponder email features under cPanel. I'm pretty sure big names have them. Just configure it under cPanel. Another way to do this is having a local program check the database for new members and using the program to send email to the new members. I did the second option for educational purposes but the first one should be more efficient.

How to hide sender email address using phpmailer?

I am using phpmailer to send email. I need to know how to hide or mask sender email address
You can specify any sender email address anyway, since SMTP by itself does not place any requirements on sender email addresses.
If the actual SMTP server you use places restrictions on email addresses (e.g. corporate servers which do not allow sender emails outside of the company domain) there's no way around that, unless of course you can influence the mail server configuration.
Update:
You say in a comment that you want to use gmail to send email where the sender's address is not a gmail address. There is no way to do that.
This is a rare situation you have here... if you do not have a mail server you can still tell PHPMailer to send from a different address just set the From attribute of the PHPMailer object to the address you want. But Wait! if your server doesn't exists, the client can't verify the account and then your mail will more likely be deleted (moved to spam in the more benevolent scenario). If you are trying to mimic third party mail, I'll help you no futher.
Note: Your mail server may be valid but clients are still unable to verify it, and thus you are getting mails delivered to spam or deleted. Check "Must Read" to below to have some inside on how to solve this.
On the other hand, if you already have a mail server, then tell PHPMailer you want to use it, set the Host and Port attributes to your domain name and port respectively. The same if you want to use an account form a different server, remember to set the attributes Username and Password correctly, you may also need to set SMTPAuth = true; and SMTPSecure = 'ssl'; depending on the server. [Note: Username and From may differ]
Now, if you want to use an account from Gmail, you could easily set an alias in Gmail to send as another account [Go to Settings-> Accounts And Import -> Send mail as -> (click) Send Mail From Another Address], that can be the case if you have a mail server but you cannot afford to have it online, you will need to start your server so you can receive the confirmation code Gmail generates to verify your account. Check recommended read for PHP side configuration details.
Lastly if for some rare circunstancies you can't tell PHPMailer to use your mail server, but you do in fact have one, and that one is able to recieve the mail... you can use AddReplyTo('me#example.com', 'My Name'); Most clients will understand that any reply to the message must be (unless explicitly defined by the user) directed to "me#example.com" in this case.
Disclaimer: I take no responsibility of any harm result of the use of the method I mention here, such as (but not limited to) your mail account getting banned.
Must read:
Coding Horror on sending mail via code
Recommended read: PHPMailer Tutorial (old version)
No need (neither a good way) to hide or mask whatsoever.
I assume you already know how to use the class you are talking about.
You probably have some variable for sending email, like
var $From = "someguy#whatever.com";
you can type whatever you want into that email address. Gmail dont care what email things is sent from.
And no, this dosent sound very legit.
One more thing: Gmail requires a gmail account to relay mails. Its no problem, it wont be visible.
You want to "show the company email address as sender" but you "didn't (sic) have any email server"?
Can anyone actually send you email at your company email address? If so, use that server which is hosting your email to send out from.
If you don't really have a company email address, then I suggest you get a gmail address like companyname#gmail.com and just send from that. Otherwise the email will appear as spam to a great many of your recipients.
Now, if the people you are about to send an email to actually signed up to be on your mailing list then you can use a third party application like Constant Contact to do your broadcasts from.
If they haven't, then I suggest you not send an email at all.
in mail headers you can have both a Sender: and a From: header which in most mail clients is displayed as either just the From or in some cases Sender on behalf of From, using this way is a nice and clean way to be able to send From a different mail address then the actual Sender mail server
This is highly illegal.
var $From = "someguy#whatever.com";
Is the only option your have for trying to hide email address. But no matter what your email will be inscribed with IP. Someone who knows what they are doing will still be able to trace the email back to the source.

Categories