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.
Related
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
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.
I have a PHP website that send a validation code when a new account is created.
My problem is since few months, a lot of those email goes in the spam folder.
I thought of a solution that is to use an "external service" to send my email instead of simply sending it via the mail function in PHP.
Question : 1) What external service should I use (I guess it would requires to have an API)?
Try using your ISP's or company's server as a relay. Use a sending address which exists, so that validation can be done on it, and bounces sent back to it. You may want to setup a separate domain for verification such as verification.example.com. You could then send the validation message from application#verification.example.com. Replace application and example as appropriate.
You may also want to look at https://serverfault.com/questions/241189/email-delivery-management-grievances#241260.
Have a look at this documentation from Google. It involves your network support including reverse lookup and Domain keys to be present. I think most of the email servers would have similar requisites.
Many times, when using the builtin mail function, the configuration isn't set up to help prevent this from happening. The reason is the Received header is set to an internal IP address, like 192.168.x.x which is used as an indicator to most spam filters. You may want to try finding a simple SMTP class that connects remotely so the headers get set properly.
Well, I'm trying to create a newsletter, that will send emails to users in a database. The newsletter itself would draw "events" and other activities from a database. Whats the best way to take that list, and put them in an email? I was thinking about putting them into an html page, then sending an html email, but not all emails support html(like school email). What would your guys recommend? Could you point me to some good resources?
Also, this is for a school project, so I cant use any open source type stuff, unfortunately :(
You are correct in your assumption that if you are creating html newsletters, you will also have to do a text based version for clients that don't support html or ones that ask to have e-mail be sent only in text. You will need to make sure your code sends both versions to recipients. You could also ask the recipients for their preference and send them the specific version that they requested.
For html e-mail it is highly recommended to read the following two articles by CampaignMonitor (they specialize in e-mail marketing sofware):
HTML E-mail Design Guidelines
Guide to CSS support in email
clients
Note that I am assuming you are asking for help with the actual construction of the html for the email not the code needed to create and send the newsletter.
Good luck with your project.
==== UPDATE ====
So it seems that you actually need help in developing this project. Since this is a homework, I will provide some general advice that should steer you in the correct direction and get you started on the project. Then, if you have any specific problems with your code, you can ask about them on Stackoverflow.
There is really two things that need to be done here:
In PHP, dynamically contruct a variable that contains the html or text versions of the e-mail that needs to be sent.
Loop through your contact list and e-mail the contents of that variable.
Sending E-mail
I will start with the sending e-mail portion, because the links provide bellow also show you how to construct the message. Also, in your comment you said you already know how to contruct an html from a database. The following links show you two ways to send e-mail. You can either use the Mail function that comes with PHP or download the PEAR_Mail package. If you are allowed to use additional libraries and want to send html e-mail, I would recommend using the PEAR_Mail, because it makes things much easier if you want to send a both an html and text version of an e-mail together.
Note: To send an e-mail you will need to use some sort of mail server. If you are using Windows, you can install the SMTP service that comes with IIS or you can use an external smtp service such as google to send your e-mails.
http://www.w3schools.com/php/php_ref_mail.asp
http://us2.php.net/manual/en/function.mail.php
http://www.webcheatsheet.com/php/send_email_text_html_attachment.php
http://pear.php.net/manual/en/package.mail.mail.php
http://pear.php.net/package/Mail_Mime/docs
Construct E-mail
The complexity here will depend on whether you just want a plain text e-mail or html. For either case you will need to read the event data from your database and add it to the message that you want to send.
Some Seudocode:
Loop through datarows
message = DataRow[EventDate] + " " + DataRow[EventName] + "\n"
Loop through recipients
mail message
Hopefully this gives you a start. I would recommend getting php to send out an e-mail of a static html or text first. Once you have that code working you can start working on adding the functionality of reading event info from a database and sending it out.
Hope this helps.
I have a form, which gathers some Information of my visitor, and when they submit the Information, it will send it to my desired email. now I need another input "file" that they can even attach their photo and send along with it to my email not on my server, I have no Idea how can I do that, I would appreciate any helps.
phpmailer is a great email engine. it has many features one of which includes sending attachments. i would give this example a look, its pretty much exactly what you are trying to do.
http://zainal.wordpress.com/2007/01/10/sending-email-attachments-in-php-using-phpmailer-class/
Check out PEAR Mail_Mime for building the e-mail with attachments and optionally PEAR Mail for sending it.
Here's a link to show you how to do the file input:
http://www.cs.tut.fi/~jkorpela/forms/file.html
When you send the email, you'll have to send the file as an attachment. This link gives the idea:
http://www.webcheatsheet.com/PHP/send_email_text_html_attachment.php#attachment
(DISCLAIMER: I haven't coded PHP for a few years, so I don't know if this is the best way to do it. I just searched Google and skimmed the first link that came up).