Configuring EMail php to work

Dragnorian
edited November -1 in Bug/Issue Reports

Hello. I have some php script that confirmed to work but it does not work on profreehosting. Could anyone of you help me make the script work with profreehosting please?
Here is the code:

<?php //--------------------------Set these paramaters-------------------------- // Subject of email sent to you. $subject = 'Subject'; // Your email address. This is where the form information will be sent. $emailadd = 'email@domain.com'; // Where to redirect after form is processed. $url = 'redirect.com'; // Makes all fields required. If set to '1' no field can be empty. If set to '0' any or all fields can be empty. $req = '0'; // --------------------------Do not edit below this line-------------------------- $text = "Submission Information:\n\n"; $space = ' '; $line = ' '; foreach ($_POST as $key => $value) { if ($req == '1') { if ($value == '') {echo "$key is empty";die;} } $j = strlen($key); if ($j >= 40) {echo "Name of form element $key cannot be longer than 40 characters";die;} $j = 20 - $j; for ($i = 1; $i <= $j; $i++) {$space .= ' ';} $value = str_replace('\n', "$line", $value); $conc = "{$key}:$space{$value}$line"; $text .= $conc; $space = ' '; } //'From: '.$emailadd.'' mail($emailadd, $subject, $text, "From: \""."WEB_CONTACT_SUBMISSION"."\"\n"); echo '<META HTTP-EQUIV=Refresh CONTENT="0; URL='.$url.'">'; ?>

Comments

  • Dragnorian
    edited November -1

    <?php //--------------------------Set these paramaters-------------------------- // Subject of email sent to you. $subject = 'Subject'; // Your email address. This is where the form information will be sent. $emailadd = 'email@domain.com'; // Where to redirect after form is processed. $url = 'redirect.com'; // Makes all fields required. If set to '1' no field can be empty. If set to '0' any or all fields can be empty. $req = '0'; // --------------------------Do not edit below this line-------------------------- $text = "Submission Information:\n\n"; $space = ' '; $line = ' '; foreach ($_POST as $key => $value) { if ($req == '1') { if ($value == '') {echo "$key is empty";die;} } $j = strlen($key); if ($j >= 40) {echo "Name of form element $key cannot be longer than 40 characters";die;} $j = 20 - $j; for ($i = 1; $i <= $j; $i++) {$space .= ' ';} $value = str_replace('\n', "$line", $value); $conc = "{$key}:$space{$value}$line"; $text .= $conc; $space = ' '; } //'From: '.$emailadd.'' mail($emailadd, $subject, $text, "From: \""."WEB_CONTACT_SUBMISSION"."\"\n"); echo '<META HTTP-EQUIV=Refresh CONTENT="0; URL='.$url.'">'; ?>
    Update: This is the proper formatted code

  • TheCrafters
    edited November -1

    @badbot said:
    I don't think it is your script as much as the "smtp.mailfrom=apache@freemail.byetcluster.com." I would say this is what your looking for: freemail.byetcluster.com [185.27.132.238]) How to implement into code is another deal.

    You must have an email account created in the control panel in order for php mailer (script) to work. Plus the MX entries are a bitch.

    My mx entries are:

    badtech.ezyro.com mx.byetcluster.com. 0 badtech.ezyro.com mx.ezyro.com. 0 cedartree.gq mx.cedartree.gq. 0 eeag.ezyro.com mx.byetcluster.com. 0

    The forum ( https://cedartree.gq/ezy/ ) registration email script did send an email. I had to change to utf8 for the email verification link to work correctly. But it has been so long ago I don't know if it still works. And no one uses the forum.

    The script would not send() until email account created, mx records added, and user (PFH email address) into the forum mail script. Third party domain email will not work. Must be a profreehost email account.

    My question is how to change it to UTF-8?

  • Dragnorian
    edited November -1

    @badbot said:
    I don't think it is your script as much as the "smtp.mailfrom=apache@freemail.byetcluster.com." I would say this is what your looking for: freemail.byetcluster.com [185.27.132.238]) How to implement into code is another deal.

    You must have an email account created in the control panel in order for php mailer (script) to work. Plus the MX entries are a bitch.

    My mx entries are:

    badtech.ezyro.com mx.byetcluster.com. 0 badtech.ezyro.com mx.ezyro.com. 0 cedartree.gq mx.cedartree.gq. 0 eeag.ezyro.com mx.byetcluster.com. 0

    The forum ( https://cedartree.gq/ezy/ ) registration email script did send an email. I had to change to utf8 for the email verification link to work correctly. But it has been so long ago I don't know if it still works. And no one uses the forum.

    The script would not send() until email account created, mx records added, and user (PFH email address) into the forum mail script. Third party domain email will not work. Must be a profreehost email account.

    So how would I add my email to the mx entries? I want to use my gmail account for it all

  • TheCrafters
    edited November -1

    @Dragnorian said:

    @badbot said:
    I don't think it is your script as much as the "smtp.mailfrom=apache@freemail.byetcluster.com." I would say this is what your looking for: freemail.byetcluster.com [185.27.132.238]) How to implement into code is another deal.

    You must have an email account created in the control panel in order for php mailer (script) to work. Plus the MX entries are a bitch.

    My mx entries are:

    badtech.ezyro.com mx.byetcluster.com. 0 badtech.ezyro.com mx.ezyro.com. 0 cedartree.gq mx.cedartree.gq. 0 eeag.ezyro.com mx.byetcluster.com. 0

    The forum ( https://cedartree.gq/ezy/ ) registration email script did send an email. I had to change to utf8 for the email verification link to work correctly. But it has been so long ago I don't know if it still works. And no one uses the forum.

    The script would not send() until email account created, mx records added, and user (PFH email address) into the forum mail script. Third party domain email will not work. Must be a profreehost email account.

    So how would I add my email to the mx entries? I want to use my gmail account for it all

    @Dragnorian said:

    @badbot said:
    I don't think it is your script as much as the "smtp.mailfrom=apache@freemail.byetcluster.com." I would say this is what your looking for: freemail.byetcluster.com [185.27.132.238]) How to implement into code is another deal.

    You must have an email account created in the control panel in order for php mailer (script) to work. Plus the MX entries are a bitch.

    My mx entries are:

    badtech.ezyro.com mx.byetcluster.com. 0 badtech.ezyro.com mx.ezyro.com. 0 cedartree.gq mx.cedartree.gq. 0 eeag.ezyro.com mx.byetcluster.com. 0

    The forum ( https://cedartree.gq/ezy/ ) registration email script did send an email. I had to change to utf8 for the email verification link to work correctly. But it has been so long ago I don't know if it still works. And no one uses the forum.

    The script would not send() until email account created, mx records added, and user (PFH email address) into the forum mail script. Third party domain email will not work. Must be a profreehost email account.

    So how would I add my email to the mx entries? I want to use my gmail account for it all

    MX Entries are custom for your domain.
    Like mine. support@greenapplicationsofficial.gq
    That is how I use my email, you can try sending a email to it and I will try to send it back so you can see that it works.
    Do not worry, I do not spam emails.
    But if it does not appear in your inbox check your spam folder.
    Sometimes it ends up in the updates folder for no reason :/

  • Dragnorian
    edited November -1

    @TheCrafters said:

    @Dragnorian said:

    @badbot said:
    I don't think it is your script as much as the "smtp.mailfrom=apache@freemail.byetcluster.com." I would say this is what your looking for: freemail.byetcluster.com [185.27.132.238]) How to implement into code is another deal.

    You must have an email account created in the control panel in order for php mailer (script) to work. Plus the MX entries are a bitch.

    My mx entries are:

    badtech.ezyro.com mx.byetcluster.com. 0 badtech.ezyro.com mx.ezyro.com. 0 cedartree.gq mx.cedartree.gq. 0 eeag.ezyro.com mx.byetcluster.com. 0

    The forum ( https://cedartree.gq/ezy/ ) registration email script did send an email. I had to change to utf8 for the email verification link to work correctly. But it has been so long ago I don't know if it still works. And no one uses the forum.

    The script would not send() until email account created, mx records added, and user (PFH email address) into the forum mail script. Third party domain email will not work. Must be a profreehost email account.

    So how would I add my email to the mx entries? I want to use my gmail account for it all

    @Dragnorian said:

    @badbot said:
    I don't think it is your script as much as the "smtp.mailfrom=apache@freemail.byetcluster.com." I would say this is what your looking for: freemail.byetcluster.com [185.27.132.238]) How to implement into code is another deal.

    You must have an email account created in the control panel in order for php mailer (script) to work. Plus the MX entries are a bitch.

    My mx entries are:

    badtech.ezyro.com mx.byetcluster.com. 0 badtech.ezyro.com mx.ezyro.com. 0 cedartree.gq mx.cedartree.gq. 0 eeag.ezyro.com mx.byetcluster.com. 0

    The forum ( https://cedartree.gq/ezy/ ) registration email script did send an email. I had to change to utf8 for the email verification link to work correctly. But it has been so long ago I don't know if it still works. And no one uses the forum.

    The script would not send() until email account created, mx records added, and user (PFH email address) into the forum mail script. Third party domain email will not work. Must be a profreehost email account.

    So how would I add my email to the mx entries? I want to use my gmail account for it all

    MX Entries are custom for your domain.
    Like mine. support@greenapplicationsofficial.gq
    That is how I use my email, you can try sending a email to it and I will try to send it back so you can see that it works.
    Do not worry, I do not spam emails.
    But if it does not appear in your inbox check your spam folder.
    Sometimes it ends up in the updates folder for no reason :/

    So how would I then set up my MX Record?

  • TheCrafters
    edited November -1

    @badbot said:

    @TheCrafters said:
    My question is how to change it to UTF-8?

    In vanilla forum had to change a line in "class.email.php". The file name would be most likely the same in any opensource script. Location of file may be different.

    Newer version updates may cause it to brake. May not.

    what line do I change on "class.email.php" is it 43 to 56?
    function __construct() { $this->PhpMailer = new \Vanilla\VanillaMailer(); $this->PhpMailer->CharSet = 'utf-8'; $this->PhpMailer->SingleTo = c('Garden.Email.SingleTo', false); $this->PhpMailer->Hostname = c('Garden.Email.Hostname', ''); $this->PhpMailer->Encoding = 'quoted-printable'; $this->clear(); $this->addHeader('Precedence', 'list'); $this->addHeader('X-Auto-Response-Suppress', 'All'); $this->setEmailTemplate(new EmailTemplate()); $this->resolveFormat(); parent::__construct(); }
    or is it a different line?

  • TheCrafters
    edited June 2018

    @badbot said:

    @TheCrafters said:
    or is it a different line?

    I have it line 42. Looks like you have the syntax just a bit off.

    $this->PhpMailer->CharSet = c('Garden.Charset', 'utf-8');

    $this->PhpMailer->CharSet = 'utf-8';
    It came that way by default.
    But I do have to say the newer version of Vanilla is a little confusing.

  • TheCrafters
    edited November -1

    @TheCrafters said:

    @badbot said:

    @TheCrafters said:
    or is it a different line?

    I have it line 42. Looks like you have the syntax just a bit off.

    $this->PhpMailer->CharSet = c('Garden.Charset', 'utf-8');

    $this->PhpMailer->CharSet = 'utf-8';
    It came that way by default.
    But I do have to say the newer version of Vanilla is a little confusing.

    and it still puts out unformatted text that looks like this: Example Forum https://forum.example.com/index.php?p=3D= /=0ATest Email=0A=0AThis is a test email message.You can configure the appe= arance of your forum's emails by navigating to the Email page in the dashbo= ard.=0A=0ACheck it out: https://forum.example.com/index.php?p=3D/
    What could be causing this?

  • Dragnorian
    edited November -1

    @badbot said:

    @Dragnorian said:
    So how would I then set up my MX Record?

    @Dragnorian

    Would be better if you posted your PFH domain name or domain name you add on. We can tell you exactly what mx records to enter.

    my domain is nerdodevelopmenttesting

  • ChrisPAR
    edited June 2018

    @Dragnorian said:

    @badbot said:

    @Dragnorian said:
    So how would I then set up my MX Record?

    @Dragnorian

    Would be better if you posted your PFH domain name or domain name you add on. We can tell you exactly what mx records to enter.

    my domain is nerdodevelopmenttesting

    dot what?
    Your domain cannot be just nerdodevelopmenttesting!

  • TheCrafters
    edited November -1

    @badbot said:
    @TheCrafters
    My bad I checked installed copy of /library/core/class.email.php looks like line 46.

    $this->PhpMailer->Encoding = '8bit';

    Line 42 is $this->PhpMailer->CharSet = 'utf-8';

    Vanilla Forum version 2.5.1

    I changed it to this:
    function __construct() { $this->PhpMailer = new \Vanilla\VanillaMailer(); $this->PhpMailer->CharSet = 'utf-8'; $this->PhpMailer->SingleTo = c('Garden.Email.SingleTo', false); $this->PhpMailer->Hostname = c('Garden.Email.Hostname', ''); $this->PhpMailer->Encoding = '8bit'; $this->clear(); $this->addHeader('Precedence', 'list'); $this->addHeader('X-Auto-Response-Suppress', 'All'); $this->setEmailTemplate(new EmailTemplate()); $this->resolveFormat(); parent::__construct(); }
    That seems to work just fine

  • TheCrafters
    edited November -1

    @ChrisPAR said:

    @Dragnorian said:

    @badbot said:

    @Dragnorian said:
    So how would I then set up my MX Record?

    @Dragnorian

    Would be better if you posted your PFH domain name or domain name you add on. We can tell you exactly what mx records to enter.

    my domain is nerdodevelopmenttesting

    dot what?
    Your domain cannot be just nerdodevelopmenttesting!

    I think I found it http://nerdodevelopmenttesting.unaux.com/

  • ChrisPAR
    edited November -1

    @TheCrafters said:

    @ChrisPAR said:

    @Dragnorian said:

    @badbot said:

    @Dragnorian said:
    So how would I then set up my MX Record?

    @Dragnorian

    Would be better if you posted your PFH domain name or domain name you add on. We can tell you exactly what mx records to enter.

    my domain is nerdodevelopmenttesting

    dot what?
    Your domain cannot be just nerdodevelopmenttesting!

    I think I found it http://nerdodevelopmenttesting.unaux.com/

    I thought of it so, but we cannot be sure.

  • ChrisPAR
    edited June 2018

    @badbot said:

    Add these mx records in the control panel under MX Entry's

    nerdodevelopmenttesting.unaux.com >> mx.byetcluster.com.
    nerdodevelopmenttesting.unaux.com >> mx.ezyro.com.

    Both with priority of zero "0".

    After it propagates, your contact form script should start sending visitors message to your gmail account. It will be from the email address you have created something@nerdodevelopmenttesting.unaux.com.

    Then you should be able to alter the contact form script to you best suit your needs.

    I do not think he will be able to add or change MX records for subdomain..
    I tried it and it didn't work.

  • TheCrafters
    edited November -1

    @ChrisPAR said:

    @badbot said:

    Add these mx records in the control panel under MX Entry's

    nerdodevelopmenttesting.unaux.com >> mx.byetcluster.com.
    nerdodevelopmenttesting.unaux.com >> mx.ezyro.com.

    Both with priority of zero "0".

    After it propagates, your contact form script should start sending visitors message to your gmail account. It will be from the email address you have created something@nerdodevelopmenttesting.unaux.com.

    Then you should be able to alter the contact form script to you best suit your needs.

    I do not think he will be able to add or change MX records for subdomain..
    I tried it and it didn't work.

    Incorrect.
    I did it with my old domain
    GreenApplicationsofficial.ezyro.com which is now down.
    I now use GreenApplicationsOfficial.gq
    But he can use MX Records on subdomains. (Via CPanel)

  • Dragnorian
    edited November -1

    @badbot said:

    Add these mx records in the control panel under MX Entry's

    nerdodevelopmenttesting.unaux.com >> mx.byetcluster.com.
    nerdodevelopmenttesting.unaux.com >> mx.unaux.com

    Both with priority of zero "0".

    After it propagates, your contact form script should start sending visitors message to your gmail account. It will be from the email address you have created something@nerdodevelopmenttesting.unaux.com.

    Then you should be able to alter the contact form script to best suit your needs.

    I did that, I added the domain with the mxentry and bytecluster and I tried to send an email but it never worked

  • ChrisPAR
    edited November -1

    What is the port for freemail.byetcluster.com as SMTP server?
    I need to config this as my SMTP server for Vanilla Forums and port 587 doesn't work!

  • ChrisPAR
    edited November -1

    @badbot said:
    No smtp/pop/imap or SSL for free services.

    https://profreehost.com/support/email

    Then, for what is freemail.byetcluster.com used?

  • Dragnorian
    edited November -1

    @badbot said:
    how long ago did you add mx entry? did you add both mx records? how was email sent, by webmail client in control panel?

    get email working from http://185.27.132.238/roundcubemail both send and receive. once that is working the contact form should work.

    If you can send and receive from webmail and not the contact form the script needs to be debugged.

    @Dragnorian

    I really do not understand the whole MX Entry type thing, this is my first time dealing with this kind of thing, I have 3 entries one is of 1wt.unaux.com with byte cluster, the other two are:
    nerdodevelopmenttesting.unaux.com mx.unaux.com. 0
    nerdodevelopmenttesting.unaux.com mx.bytecluster.com. 0

  • Dragnorian
    edited November -1

    I tried to send it through my website @badbot , I do not know my credentials for the roundcube

  • Dragnorian
    edited November -1

    @TheCrafters @badbot So after I created the account, I tried again through my site and I couldn't get the email to go through, what do I do?

  • Dragnorian
    edited November -1

    @badbot I have sent the email to that address

  • Dragnorian
    edited November -1

    @badbot said:
    @Dragnorian
    let me know if you receive reply.

    I have received the reply my good sir

  • Dragnorian
    edited November -1

    @badbot said:
    @Dragnorian
    Okay so if the contact form is still not working, debugging is needed.

    Is that a wordpress contact form? If so you may be able to alter config inside the wordpress admin console. It may be trying to send from old config trying to authenticate old smtp mail server.

    I'm getting 403 on submit
    http://nerdodevelopmenttesting.unaux.com/send_contact.php?

    then lands on

    http://nerdodevelopmenttesting.unaux.com/redirect.com

    I would have to see the source of send_contact.php

    I just changed the redirection, it shouldn't lead anywhere. This isn't any kind of wordpress, custom made. It worked on my school server that I no longer have access too, here is the source:
    `
    <?php //--------------------------Set these paramaters-------------------------- // Subject of email sent to you. $subject = 'Subject'; // Your email address. This is where the form information will be sent. $emailadd = 'nerdosoftwaredevelopment@gmail.com'; // Where to redirect after form is processed. $url = 'redirect.com'; // Makes all fields required. If set to '1' no field can be empty. If set to '0' any or all fields can be empty. $req = '0'; // --------------------------Do not edit below this line-------------------------- $text = "Submission Information:\n\n"; $space = ' '; $line = ' '; foreach ($_POST as $key => $value) { if ($req == '1') { if ($value == '') {echo "$key is empty";die;} } $j = strlen($key); if ($j >= 40) {echo "Name of form element $key cannot be longer than 40 characters";die;} $j = 20 - $j; for ($i = 1; $i <= $j; $i++) {$space .= ' ';} $value = str_replace('\n', "$line", $value); $conc = "{$key}:$space{$value}$line"; $text .= $conc; $space = ' '; } //'From: '.$emailadd.'' mail($emailadd, $subject, $text, "From: \""."WEB_CONTACT_SUBMISSION"."\"\n"); echo '<META HTTP-EQUIV=Refresh CONTENT="0; URL='.$url.'">'; ?>

    `

  • Dragnorian
    edited November -1

    <?php //--------------------------Set these paramaters-------------------------- // Subject of email sent to you. $subject = 'Subject'; // Your email address. This is where the form information will be sent. $emailadd = 'nerdosoftwaredevelopment@gmail.com'; // Where to redirect after form is processed. $url = 'redirect.com'; // Makes all fields required. If set to '1' no field can be empty. If set to '0' any or all fields can be empty. $req = '0'; // --------------------------Do not edit below this line-------------------------- $text = "Submission Information:\n\n"; $space = ' '; $line = ' '; foreach ($_POST as $key => $value) { if ($req == '1') { if ($value == '') {echo "$key is empty";die;} } $j = strlen($key); if ($j >= 40) {echo "Name of form element $key cannot be longer than 40 characters";die;} $j = 20 - $j; for ($i = 1; $i <= $j; $i++) {$space .= ' ';} $value = str_replace('\n', "$line", $value); $conc = "{$key}:$space{$value}$line"; $text .= $conc; $space = ' '; } //'From: '.$emailadd.'' mail($emailadd, $subject, $text, "From: \""."WEB_CONTACT_SUBMISSION"."\"\n"); echo '<META HTTP-EQUIV=Refresh CONTENT="0; URL='.$url.'">'; ?>

  • Dragnorian
    edited November -1

    @badbot said:
    It seems like the form is processing. It may be the mx records have not propagated yet. If you don't get any emails in your gmail (spam box) by the end of tomorrow, and no bounce in your roundcube. Try changing the gmail address to you roundcube address. Try the form with that. Just a test.

    It looks like it should be working. If I get time I'll look at the phpmailer On the forum and see how they do it.

    I also did try to use my roundcube email and never got a bounce to it

  • Dragnorian
    edited November -1

    @badbot said:
    It seems like the form is processing. It may be the mx records have not propagated yet. If you don't get any emails in your gmail (spam box) by the end of tomorrow, and no bounce in your roundcube. Try changing the gmail address to you roundcube address. Try the form with that. Just a test.

    It looks like it should be working. If I get time I'll look at the phpmailer On the forum and see how they do it.

    Hey mate, so I waited some days to see if the issue would work, it sadly still does not. However I did see the forwarder option and I put in my roundcube email and to forward it to my gmail account but it would not allow me too. What else can we do?

  • ChrisPAR
    edited November -1

    @Dragnorian said:

    @badbot said:
    It seems like the form is processing. It may be the mx records have not propagated yet. If you don't get any emails in your gmail (spam box) by the end of tomorrow, and no bounce in your roundcube. Try changing the gmail address to you roundcube address. Try the form with that. Just a test.

    It looks like it should be working. If I get time I'll look at the phpmailer On the forum and see how they do it.

    Hey mate, so I waited some days to see if the issue would work, it sadly still does not. However I did see the forwarder option and I put in my roundcube email and to forward it to my gmail account but it would not allow me too. What else can we do?

    Hi,
    Gmail is blocking forwarder emails and automatically deleting them.
    You may use antoher service to forward emails to like Outlook Mail, Tutanota, ProtonMail etc.