sending email from php webform to address other than website host

923 views Asked by At

I have developed a website hosted on 1and1 which has a webform for submitting contact information.

The client wants to retain his current GMAIL address for receiving the emails.

Can I use his email address in the php mailer settings? My understanding is that 1and1 will reject the website generated emails unless the from address is the same as his domain name. I am new to this...

2

There are 2 answers

1
Andrew On BEST ANSWER

You can add a FROM: [email protected] header in the PHP mail() function, which will show up on the recipient mail client as being from someone at [email protected]. Some mail servers may tag it as spam if they identify the email as not coming from a mail server which is authorised to send emails for that domain.

Additionally, 1and1 may drop emails from being sent from domains other than those hosted by them/authorised by them. It is probably worth contacting them to clarify this.

Something like the following should do what you want, provided there are no blocks etc. But as Constantine says above, it may go into a spam folder etc.

mail("[email protected]", "Subject here...", "Message Here", "From: [email protected]");

You could always look into setting a Reply-To: header (similar to the From: above if you need to send it from a domain hosted by 1and1.

0
Constantine Loukas On

I can't see why it wouldn't work. Try sending an email to a test gmail account and see if it works. I have a feeling it will end up on the spam folder though.

mail('[email protected]', 'Test Subject', 'Test message');